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