当前位置: 首页>>代码示例>>Java>>正文


Java Context.setConfigFile方法代码示例

本文整理汇总了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;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:33,代码来源:Tomcat.java

示例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;			
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:73,代码来源:EmbeddedTomcat.java


注:本文中的org.apache.catalina.Context.setConfigFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。