mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
Read configuration from servlet context.
This commit is contained in:
parent
24dbd884ad
commit
8bb9bf11d5
@ -28,7 +28,7 @@
|
||||
|
||||
package org.openuds.guacamole;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer;
|
||||
import org.apache.guacamole.tunnel.TunnelRequestService;
|
||||
import org.openuds.guacamole.config.ConfigurationService;
|
||||
@ -38,10 +38,10 @@ import org.openuds.guacamole.connection.ConnectionService;
|
||||
* Guice module which binds classes required by the OpenUDS integration of
|
||||
* Apache Guacamole.
|
||||
*/
|
||||
public class UDSModule extends AbstractModule {
|
||||
public class UDSModule extends ServletModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
protected void configureServlets() {
|
||||
|
||||
// Serve servlets, etc. with Guice
|
||||
bind(GuiceContainer.class);
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
package org.openuds.guacamole.config;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
@ -35,6 +36,7 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Properties;
|
||||
import javax.servlet.ServletContext;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
import org.slf4j.Logger;
|
||||
@ -161,13 +163,18 @@ public class ConfigurationService {
|
||||
* resulting errors will simply be logged. If configuration information
|
||||
* cannot be read, attempts to retrieve this information later through calls
|
||||
* to the getters of this service will fail with appropriate exceptions.
|
||||
*
|
||||
* @param context
|
||||
* The ServletContext associated with the servlet container which is
|
||||
* serving this web application.
|
||||
*/
|
||||
public ConfigurationService() {
|
||||
@Inject
|
||||
public ConfigurationService(ServletContext context) {
|
||||
|
||||
// Read tunnel.properties
|
||||
Properties config = new Properties();
|
||||
try {
|
||||
config.load(ConfigurationService.class.getResourceAsStream("/WEB-INF/tunnel.properties"));
|
||||
config.load(context.getResourceAsStream("/WEB-INF/tunnel.properties"));
|
||||
}
|
||||
catch (IOException e) {
|
||||
logger.error("Unable to read tunnel.properties.", e);
|
||||
|
Loading…
Reference in New Issue
Block a user