Author: asankha Date: Wed Jun 4 09:02:23 2008 New Revision: 17933 URL: http://wso2.org/svn/browse/wso2?view=rev&revision=17933
Log: fix ESBJAVA-513 by committing patch by Eric Modified: branches/esb/java/1.7/esb/java/modules/distribution/src/main/conf/tomcat/tomcat.properties branches/esb/java/1.7/esb/java/modules/startup/src/main/java/org/wso2/esb/TomcatServer.java Modified: branches/esb/java/1.7/esb/java/modules/distribution/src/main/conf/tomcat/tomcat.properties URL: http://wso2.org/svn/browse/wso2/branches/esb/java/1.7/esb/java/modules/distribution/src/main/conf/tomcat/tomcat.properties?rev=17933&r1=17932&r2=17933&view=diff ============================================================================== --- branches/esb/java/1.7/esb/java/modules/distribution/src/main/conf/tomcat/tomcat.properties (original) +++ branches/esb/java/1.7/esb/java/modules/distribution/src/main/conf/tomcat/tomcat.properties Wed Jun 4 09:02:23 2008 @@ -29,7 +29,16 @@ TrustStore.Type=JKS TrustStore.Password=password +############################################################################## +# set this variable to true if you are in a production environment +# (no optional contexts like docs and samples will be loaded) +############################################################################## +ProductionEnvironment=false + + +################################################### # tune these only if you require.. the defaults should be generally sufficient +################################################### #SslProtocol=TLS #MaxHttpHeaderSize=8192 #MaxThreads=150 Modified: branches/esb/java/1.7/esb/java/modules/startup/src/main/java/org/wso2/esb/TomcatServer.java URL: http://wso2.org/svn/browse/wso2/branches/esb/java/1.7/esb/java/modules/startup/src/main/java/org/wso2/esb/TomcatServer.java?rev=17933&r1=17932&r2=17933&view=diff ============================================================================== --- branches/esb/java/1.7/esb/java/modules/startup/src/main/java/org/wso2/esb/TomcatServer.java (original) +++ branches/esb/java/1.7/esb/java/modules/startup/src/main/java/org/wso2/esb/TomcatServer.java Wed Jun 4 09:02:23 2008 @@ -30,7 +30,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.tomcat.util.IntrospectionUtils; - import java.io.File; import java.io.IOException; import java.net.InetAddress; @@ -39,9 +38,11 @@ /** * The embedded Tomcat server that will host the ESB console */ - public class TomcatServer { + private static final String WEBAPP_DIR = "webapp"; + private static final String[] OPTIONAL_CONTEXT_LIST = { "docs", "samples" }; + private static Log log = LogFactory.getLog(TomcatServer.class); private Embedded embedded; private Properties props = null; @@ -64,11 +65,7 @@ embedded.setCatalinaHome( new File(".").getAbsolutePath() + File.separator + "tomcat"); - - String webappsDir = "webapp"; - String docsDir = "docs"; - String samplesDir = "samples"; - + // set the memory realm MemoryRealm memRealm = new MemoryRealm(); embedded.setRealm(memRealm); @@ -81,18 +78,23 @@ embedded.addEngine(engine); // Create a default virtual host - Host defaultHost = embedded.createHost(host, webappsDir); + Host defaultHost = embedded.createHost(host, WEBAPP_DIR); engine.addChild(defaultHost); + + // Add context for administration webapp String esbContextPath = getTomcatProperty("ContextPath", "/esb"); - - Context esbContext = embedded.createContext(esbContextPath, new File(webappsDir).getAbsolutePath()); - defaultHost.addChild(esbContext); - - Context docsContext = embedded.createContext("/docs", new File(docsDir).getAbsolutePath()); - defaultHost.addChild(docsContext); - - Context samplesContext = embedded.createContext("/samples", new File(samplesDir).getAbsolutePath()); - defaultHost.addChild(samplesContext); + Context esbContext = embedded.createContext(esbContextPath, new File(WEBAPP_DIR).getAbsolutePath()); + defaultHost.addChild(esbContext); + + // Add additional contexts for non-production environments + boolean productionEnvironment = Boolean.parseBoolean(getTomcatProperty("ProductionEnvironment")); + if (!productionEnvironment) { + for (int i = 0; i < OPTIONAL_CONTEXT_LIST.length; i++) { + String contextName = OPTIONAL_CONTEXT_LIST[i]; + Context context = embedded.createContext("/" + contextName, new File(contextName).getAbsolutePath()); + defaultHost.addChild(context); + } + } defaultHost.setDeployOnStartup(true); embedded.setUseNaming(true); _______________________________________________ Esb-java-dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev
