本文整理汇总了Java中org.apache.catalina.Context.setConfigFile方法的典型用法代码示例。如果您正苦于以下问题:Java Context.setConfigFile方法的具体用法?Java Context.setConfigFile怎么用?Java Context.setConfigFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.Context
的用法示例。
在下文中一共展示了Context.setConfigFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addWebapp
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* @see #addWebapp(String, String)
*
* @param name Ignored. The contextPath will be used
*
* @deprecated Use {@link #addWebapp(Host, String, String)}
*/
@Deprecated
public Context addWebapp(Host host, String contextPath, String name, String docBase) {
silence(host, contextPath);
Context ctx = createContext(host, contextPath);
ctx.setPath(contextPath);
ctx.setDocBase(docBase);
ctx.addLifecycleListener(new DefaultWebXmlListener());
ctx.setConfigFile(getWebappConfigFile(docBase, contextPath));
ContextConfig ctxCfg = new ContextConfig();
ctx.addLifecycleListener(ctxCfg);
// prevent it from looking ( if it finds one - it'll have dup error )
ctxCfg.setDefaultWebXml(noDefaultWebXmlPath());
if (host == null) {
getHost().addChild(ctx);
} else {
host.addChild(ctx);
}
return ctx;
}
示例2: start
import org.apache.catalina.Context; //导入方法依赖的package包/类
/**
* Starts the Tomcat server.
*/
public void start() {
try {
System.out.println("(EmbeddedTomcat) Creating the embedded Tomcat servlet container");
System.out.println("(EmbeddedTomcat) Catalina home: " + tomcatHome);
System.setProperty("catalina.home", tomcatHome);
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true");
// Create an embedded server
System.out.println("(EmbeddedTomcat) Creating a new instance of EmbeddedTomcat");
embedded = new Tomcat();
embedded.enableNaming();
// Assemble and install a default HTTP connector
int httpConnectorPort = 8080;
// We must load the engine properties first
EnginePropertiesManager.loadProperties();
String convertigoServer = com.twinsoft.convertigo.engine.EnginePropertiesManager.getProperty(
com.twinsoft.convertigo.engine.EnginePropertiesManager.PropertyName.APPLICATION_SERVER_CONVERTIGO_URL);
System.out.println("(EmbeddedTomcat) Convertigo server property: " + convertigoServer);
int i = convertigoServer.indexOf(':', 6);
if (i != -1) {
int j = convertigoServer.indexOf("/convertigo");
httpConnectorPort = Integer.parseInt(convertigoServer.substring(i+1, j));
}
embedded.setPort(httpPort = httpConnectorPort);
int httpsConnectorPort = httpConnectorPort + 1;
System.out.println("(EmbeddedTomcat) Installing the embedded HTTPS connector listening on port " + httpsConnectorPort);
Connector connector = new Connector();
connector.setPort(httpsConnectorPort);
connector.setSecure(true);
connector.setScheme("https");
connector.setAttribute("keystorePass", "password");
connector.setAttribute("keystoreFile", tomcatHome + "/conf/.keystore");
connector.setAttribute("clientAuth", false);
connector.setAttribute("sslProtocol", "TLS");
connector.setAttribute("SSLEnabled", true);
embedded.getService().addConnector(connector);
Context context = embedded.addWebapp("", tomcatHome + "webapps/ROOT");
context.setParentClassLoader(this.getClass().getClassLoader());
context = embedded.addWebapp("/convertigo", com.twinsoft.convertigo.engine.Engine.WEBAPP_PATH);
context.setParentClassLoader(this.getClass().getClassLoader());
File configFile = new File(com.twinsoft.convertigo.engine.Engine.USER_WORKSPACE_PATH + "/studio/context.xml");
if (configFile.exists()) {
System.out.println("(EmbeddedTomcat) Set convertigo webapp config file to " + configFile.getAbsolutePath());
context.setConfigFile(configFile.toURI().toURL());
}
// Start the embedded server
System.out.println("(EmbeddedTomcat) Starting the server");
embedded.start();
System.out.println("(EmbeddedTomcat) Server successfully started!");
}
catch(Throwable e) {
String stackTrace = Log.getStackTrace(e);
System.out.println("(EmbeddedTomcat) Unexpected exception while launching Tomcat:\n" + stackTrace);
Engine.isStartFailed = true;
}
}