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


Java ContextConfig类代码示例

本文整理汇总了Java中org.apache.catalina.startup.ContextConfig的典型用法代码示例。如果您正苦于以下问题:Java ContextConfig类的具体用法?Java ContextConfig怎么用?Java ContextConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ContextConfig类属于org.apache.catalina.startup包,在下文中一共展示了ContextConfig类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createStandardContext

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
/**
 * Create a new StandardContext.
 *
 * @param parent MBean Name of the associated parent component
 * @param path The context path for this Context
 * @param docBase Document base directory (or WAR) for this Context
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardContext(String parent, String path,
                                    String docBase)
    throws Exception {
    
    // Create a new StandardContext instance
    StandardContext context = new StandardContext();    
    path = getPathStr(path);
    context.setPath(path);
    context.setDocBase(docBase);
    ContextConfig contextConfig = new ContextConfig();
    context.addLifecycleListener(contextConfig);

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    Server server = ServerFactory.getServer();
    Service service = server.findService(pname.getKeyProperty("service"));
    Engine engine = (Engine) service.getContainer();
    Host host = (Host) engine.findChild(pname.getKeyProperty("host"));

    // Add context to the host
    host.addChild(context);
    
    // Return the corresponding MBean name
    ManagedBean managed = registry.findManagedBean("StandardContext");

    ObjectName oname =
        MBeanUtils.createObjectName(managed.getDomain(), context);
    return (oname.toString());

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:40,代码来源:MBeanFactory.java

示例2: addWebapp

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
public Context addWebapp(Host host, String contextPath, String docBase, ContextConfig config) {
if(hack()){
       if (host instanceof StandardHost) {
           ((StandardHost) host).setContextClass(contextClass.getName());
       }
}
Context ctx = super.addWebapp(host, contextPath, docBase, config);
return ctx;

  }
 
开发者ID:wayshall,项目名称:onetwo,代码行数:11,代码来源:JFishTomcat.java

示例3: init

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
protected void init(final String contextRoot, final String resourceBase) throws ServletException, IOException {
    final Path basePath = Files.createTempDirectory(DEFAULT_TOMCAT_BASE_TEMP_DIR);
    setBaseDir(basePath.toString());

    if (StringUtils.isNotEmpty(resourceBase)) {
        this.resourceBase = resourceBase;
    }

    initExecutor();
    initConnector();

    final ContextConfig conf = new ContextConfig();
    final StandardContext ctx = (StandardContext) this.addWebapp(getHost(), contextRoot, new File(this.resourceBase).getAbsolutePath(), conf);
    createGlobalXml();
    conf.setDefaultWebXml(globalWebXml.getAbsolutePath());

    for (LifecycleListener listen : ctx.findLifecycleListeners()) {
        if (listen instanceof DefaultWebXmlListener) {
            ctx.removeLifecycleListener(listen);
        }
    }

    ctx.setParentClassLoader(TomcatCustomServer.class.getClassLoader());

    //Disable TLD scanning by default
    if (System.getProperty(Constants.SKIP_JARS_PROPERTY) == null && System.getProperty(Constants.SKIP_JARS_PROPERTY) == null) {
        LOGGER.debug("disabling TLD scanning");
        StandardJarScanFilter jarScanFilter = (StandardJarScanFilter) ctx.getJarScanner().getJarScanFilter();
        jarScanFilter.setTldSkip("*");
    }
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:32,代码来源:TomcatCustomServer.java

示例4: createDefaultContext

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
private Context createDefaultContext(String contextPath, String docBase) {
	StandardContext context = new StandardContext();

	context.setDocBase(docBase);
	context.setPath(contextPath);

	ContextConfig config = new ContextConfig();
	context.addLifecycleListener(config);
	return context;
}
 
开发者ID:BeamFoundry,项目名称:spring-osgi,代码行数:11,代码来源:TomcatWarDeployer.java

示例5: main

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
public static void main(String[] args) {
  System.setProperty("catalina.base", System.getProperty("user.dir"));
  Connector connector = new HttpConnector();

  Context context = new StandardContext();
  // StandardContext's start method adds a default mapper
  context.setPath("/app1");
  context.setDocBase("app1");
  LifecycleListener listener = new ContextConfig();
  ((Lifecycle) context).addLifecycleListener(listener);

  Host host = new StandardHost();
  host.addChild(context);
  host.setName("localhost");
  host.setAppBase("webapps");

  Loader loader = new WebappLoader();
  context.setLoader(loader);
  connector.setContainer(host);
  try {
    connector.initialize();
    ((Lifecycle) connector).start();
    ((Lifecycle) host).start();
    Container[] c = context.findChildren();
    int length = c.length;
    for (int i=0; i<length; i++) {
      Container child = c[i];
      System.out.println(child.getName());
    }

    // make the application wait until we press a key.
    System.in.read();
    ((Lifecycle) host).stop();
  }
  catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:eclipsky,项目名称:HowTomcatWorks,代码行数:39,代码来源:Bootstrap.java

示例6: createStandardContext

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
/**
 * Create a new StandardContext.
 *
 * @param parent MBean Name of the associated parent component
 * @param path The context path for this Context
 * @param docBase Document base directory (or WAR) for this Context
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardContext(String parent, 
                                    String path,
                                    String docBase,
                                    boolean xmlValidation,
                                    boolean xmlNamespaceAware,
                                    boolean tldValidation,
                                    boolean tldNamespaceAware)
    throws Exception {

    // Create a new StandardContext instance
    StandardContext context = new StandardContext();
    path = getPathStr(path);
    context.setPath(path);
    context.setDocBase(docBase);
    context.setXmlValidation(xmlValidation);
    context.setXmlNamespaceAware(xmlNamespaceAware);
    context.setTldValidation(tldValidation);
    context.setTldNamespaceAware(tldNamespaceAware);
    
    ContextConfig contextConfig = new ContextConfig();
    context.addLifecycleListener(contextConfig);

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ObjectName deployer = new ObjectName(pname.getDomain()+
                                         ":type=Deployer,host="+
                                         pname.getKeyProperty("host"));
    if(mserver.isRegistered(deployer)) {
        String contextName = context.getName();
        mserver.invoke(deployer, "addServiced",
                       new Object [] {contextName},
                       new String [] {"java.lang.String"});
        String configPath = (String)mserver.getAttribute(deployer,
                                                         "configBaseName");
        String baseName = context.getBaseName();
        File configFile = new File(new File(configPath), baseName+".xml");
        if (configFile.isFile()) {
            context.setConfigFile(configFile.toURI().toURL());
        }
        mserver.invoke(deployer, "manageApp",
                       new Object[] {context},
                       new String[] {"org.apache.catalina.Context"});
        mserver.invoke(deployer, "removeServiced",
                       new Object [] {contextName},
                       new String [] {"java.lang.String"});
    } else {
        log.warn("Deployer not found for "+pname.getKeyProperty("host"));
        Service service = getService(pname);
        Engine engine = (Engine) service.getContainer();
        Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
        host.addChild(context);
    }

    // Return the corresponding MBean name
    return context.getObjectName().toString();

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:67,代码来源:MBeanFactory.java

示例7: createStandardContext

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
/**
 * Create a new StandardContext.
 *
 * @param parent MBean Name of the associated parent component
 * @param path The context path for this Context
 * @param docBase Document base directory (or WAR) for this Context
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardContext(String parent, 
                                    String path,
                                    String docBase,
                                    boolean xmlValidation,
                                    boolean xmlNamespaceAware,
                                    boolean tldValidation,
                                    boolean tldNamespaceAware)
    throws Exception {

    // Create a new StandardContext instance
    StandardContext context = new StandardContext();
    path = getPathStr(path);
    context.setPath(path);
    context.setDocBase(docBase);
    context.setXmlValidation(xmlValidation);
    context.setXmlNamespaceAware(xmlNamespaceAware);
    context.setTldValidation(tldValidation);
    context.setTldNamespaceAware(tldNamespaceAware);
    
    ContextConfig contextConfig = new ContextConfig();
    context.addLifecycleListener(contextConfig);

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ObjectName deployer = new ObjectName(pname.getDomain()+
                                         ":type=Deployer,host="+
                                         pname.getKeyProperty("host"));
    if(mserver.isRegistered(deployer)) {
        String contextPath = context.getPath();
        mserver.invoke(deployer, "addServiced",
                       new Object [] {contextPath},
                       new String [] {"java.lang.String"});
        String configPath = (String)mserver.getAttribute(deployer,
                                                         "configBaseName");
        String baseName = getConfigFile(contextPath);
        File configFile = new File(new File(configPath), baseName+".xml");
        context.setConfigFile(configFile.getAbsolutePath());
        mserver.invoke(deployer, "manageApp",
                       new Object[] {context},
                       new String[] {"org.apache.catalina.Context"});
        mserver.invoke(deployer, "removeServiced",
                       new Object [] {contextPath},
                       new String [] {"java.lang.String"});
    } else {
        log.warn("Deployer not found for "+pname.getKeyProperty("host"));
        Service service = getService(pname);
        Engine engine = (Engine) service.getContainer();
        Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
        host.addChild(context);
    }

    // Return the corresponding MBean name
    ObjectName oname = context.getJmxName();

    return (oname.toString());

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:67,代码来源:MBeanFactory.java

示例8: createStandardContext

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
/**
 * Create a new StandardContext.
 *
 * @param parent
 *            MBean Name of the associated parent component
 * @param path
 *            The context path for this Context
 * @param docBase
 *            Document base directory (or WAR) for this Context
 *
 * @exception Exception
 *                if an MBean cannot be created or registered
 */
public String createStandardContext(String parent, String path, String docBase, boolean xmlValidation,
		boolean xmlNamespaceAware, boolean tldValidation, boolean tldNamespaceAware) throws Exception {

	Where.amI();
	// Create a new StandardContext instance
	StandardContext context = new StandardContext();

	path = getPathStr(path);
	context.setPath(path);

	context.setDocBase(docBase);
	context.setXmlValidation(xmlValidation);
	context.setXmlNamespaceAware(xmlNamespaceAware);
	context.setTldValidation(tldValidation);
	context.setTldNamespaceAware(tldNamespaceAware);

	ContextConfig contextConfig = new ContextConfig();
	context.addLifecycleListener(contextConfig);

	// Add the new instance to its parent component
	ObjectName pname = new ObjectName(parent);
	ObjectName deployer = new ObjectName(pname.getDomain() + ":type=Deployer,host=" + pname.getKeyProperty("host"));
	if (mserver.isRegistered(deployer)) {
		String contextName = context.getName();
		mserver.invoke(deployer, "addServiced", new Object[] { contextName }, new String[] { "java.lang.String" });
		String configPath = (String) mserver.getAttribute(deployer, "configBaseName");
		String baseName = context.getBaseName();
		File configFile = new File(new File(configPath), baseName + ".xml");
		if (configFile.isFile()) {
			context.setConfigFile(configFile.toURI().toURL());
		}
		mserver.invoke(deployer, "manageApp", new Object[] { context },
				new String[] { "org.apache.catalina.Context" });
		mserver.invoke(deployer, "removeServiced", new Object[] { contextName },
				new String[] { "java.lang.String" });
	} else {
		log.warn("Deployer not found for " + pname.getKeyProperty("host"));
		Service service = getService(pname);
		Engine engine = (Engine) service.getContainer();
		Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
		host.addChild(context);
	}

	// Return the corresponding MBean name
	return context.getObjectName().toString();

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:61,代码来源:MBeanFactory.java

示例9: publish

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public synchronized Endpoint publish(ServiceDomain domain, String context, List<Object> instances, Map<String, String> contextParams) throws Exception {
    Host host = ServerUtil.getDefaultHost().getHost();
    StandardContext serverContext = (StandardContext) host.findChild("/" + context);
    if (serverContext == null) {
        serverContext = new StandardContext();
        serverContext.setPath("/" + context);
        File docBase = new File(SERVER_TEMP_DIR, context);
        if (!docBase.exists()) {
            if (!docBase.mkdirs()) {
                throw ExtensionMessages.MESSAGES.unableToCreateTempDirectory(docBase.getPath());
            }
        }
        serverContext.setDocBase(docBase.getPath());
        serverContext.addLifecycleListener(new ContextConfig());

        final Loader loader = new WebCtxLoader(instances.get(0).getClass().getClassLoader());
        loader.setContainer(host);
        serverContext.setLoader(loader);
        serverContext.setInstanceManager(new LocalInstanceManager());

        Wrapper wrapper = serverContext.createWrapper();
        wrapper.setName(SERVLET_NAME);
        wrapper.setServletClass(SERVLET_CLASS);
        wrapper.setLoadOnStartup(1);
        serverContext.addChild(wrapper);
        serverContext.addServletMapping("/*", SERVLET_NAME);
        serverContext.addApplicationListener(LISTENER_CLASS);

        if (contextParams != null) {
            for (Map.Entry<String, String> cp : contextParams.entrySet()) {
                serverContext.addParameter(cp.getKey(), cp.getValue());
            }
        }

        host.addChild(serverContext);
        serverContext.create();
        serverContext.start();
        LOG.info("Published RESTEasy context " + serverContext.getPath());
    }
    while (serverContext.isStarting()) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException ie) {
            // Ignore
            if (LOG.isDebugEnabled()) {
                LOG.debug("Spent sometime to start context.");
            }
        }
    }
    if (serverContext.isStarted()) {
        Registry registry = (Registry)serverContext.getServletContext().getAttribute(Registry.class.getName());
        List<Class<?>> classes = new ArrayList<Class<?>>();
        // Add as singleton instance
        for (Object instance : instances) {
            registry.addSingletonResource(instance);
            classes.add(instance.getClass());
        }
        RESTEasyResource resource = new RESTEasyResource();
        resource.setClasses(classes);
        resource.setContext(serverContext);
        return resource;
    } else {
        throw ExtensionMessages.MESSAGES.unableToStartContext(context, new RuntimeException("Context not yet started"));
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:69,代码来源:RESTEasyResourcePublisher.java

示例10: publish

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public synchronized Endpoint publish(ServiceDomain domain, String context, InboundHandler handler) throws Exception {
    
    Host host = ServerUtil.getDefaultHost().getHost();
    StandardContext serverContext = (StandardContext) host.findChild("/" + context);
    if (serverContext == null) {
        serverContext = new StandardContext();
        serverContext.setPath("/" + context);
        File docBase = new File(SERVER_TEMP_DIR, context);
        if (!docBase.exists()) {
            if (!docBase.mkdirs()) {
                throw ExtensionMessages.MESSAGES.unableToCreateTempDirectory(docBase.getPath());
            }
        }
        serverContext.setDocBase(docBase.getPath());
        serverContext.addLifecycleListener(new ContextConfig());

        final Loader loader = new WebCtxLoader(Thread.currentThread().getContextClassLoader());
        loader.setContainer(host);
        serverContext.setLoader(loader);
        serverContext.setInstanceManager(new LocalInstanceManager());

        Wrapper wrapper = serverContext.createWrapper();
        wrapper.setName(SERVLET_NAME);
        wrapper.setServletClass(HttpGatewayServlet.class.getName());
        wrapper.setServlet(new HttpGatewayServlet());
        wrapper.setLoadOnStartup(1);
        serverContext.addChild(wrapper);
        serverContext.addServletMapping("/*", SERVLET_NAME);

        host.addChild(serverContext);
        serverContext.create();
        serverContext.start();
        HttpGatewayServlet instance = (HttpGatewayServlet) wrapper.getServlet();
        instance.setHandler(handler);
        LOG.info("Published HTTP context " + serverContext.getPath());
    } else {
        throw ExtensionMessages.MESSAGES.contextAlreadyExists(context);
    }
    return new JBossWebEndpoint(serverContext);
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:44,代码来源:JBossWebEndpointPublisher.java

示例11: start

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
@Override
public synchronized void start() throws Exception {
    // If the remote listener is already started, just return.
    if (_started) {
        return;
    }
    
    Host host = ServerUtil.getDefaultHost().getHost();
    _serverContext = (StandardContext) host.findChild("/" + _contextName);
    if (_serverContext == null) {
        _serverContext = new StandardContext();
        _serverContext.setPath("/" + _contextName);
        File docBase = new File(SERVER_TEMP_DIR, _contextName);
        if (!docBase.exists()) {
            if (!docBase.mkdirs()) {
                throw ExtensionMessages.MESSAGES.unableToCreateTempDirectory(docBase.getPath());
            }
        }
        _serverContext.setDocBase(docBase.getPath());
        _serverContext.addLifecycleListener(new ContextConfig());

        final Loader loader = new WebCtxLoader(Thread.currentThread().getContextClassLoader());
        loader.setContainer(host);
        _serverContext.setLoader(loader);
        _serverContext.setInstanceManager(new LocalInstanceManager());

        Wrapper wrapper = _serverContext.createWrapper();
        wrapper.setName(SERVLET_NAME);
        wrapper.setServletClass(SwitchYardRemotingServlet.class.getName());
        wrapper.setLoadOnStartup(1);
        _serverContext.addChild(wrapper);
        _serverContext.addServletMapping("/*", SERVLET_NAME);
        

        host.addChild(_serverContext);
        _serverContext.create();
        _serverContext.start();
        

        SwitchYardRemotingServlet remotingServlet = (SwitchYardRemotingServlet) wrapper.getServlet();
        remotingServlet.setEndpointPublisher(this);
        _log.info("Published Remote Service Endpoint " + _serverContext.getPath());
        
        _started = true;
    } else {
        throw ExtensionMessages.MESSAGES.contextAlreadyExists(_contextName);
    }
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:49,代码来源:RemoteEndpointListener.java

示例12: createStandardContext

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
/**
 * Create a new StandardContext.
 *
 * @param parent MBean Name of the associated parent component
 * @param path The context path for this Context
 * @param docBase Document base directory (or WAR) for this Context
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createStandardContext(String parent, 
                                    String path,
                                    String docBase,
                                    boolean xmlValidation,
                                    boolean xmlNamespaceAware,
                                    boolean tldValidation,
                                    boolean tldNamespaceAware)
    throws Exception {

    // Create a new StandardContext instance
    StandardContext context = new StandardContext();
    path = getPathStr(path);
    context.setPath(path);
    context.setDocBase(docBase);
    context.setXmlValidation(xmlValidation);
    context.setXmlNamespaceAware(xmlNamespaceAware);
    context.setTldValidation(tldValidation);
    context.setTldNamespaceAware(tldNamespaceAware);
    
    ContextConfig contextConfig = new ContextConfig();
    context.addLifecycleListener(contextConfig);

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ObjectName deployer = new ObjectName(pname.getDomain()+
                                         ":type=Deployer,host="+
                                         pname.getKeyProperty("host"));
    if(mserver.isRegistered(deployer)) {
        String contextName = context.getName();
        mserver.invoke(deployer, "addServiced",
                       new Object [] {contextName},
                       new String [] {"java.lang.String"});
        String configPath = (String)mserver.getAttribute(deployer,
                                                         "configBaseName");
        String baseName = context.getBaseName();
        File configFile = new File(new File(configPath), baseName+".xml");
        context.setConfigFile(configFile.toURI().toURL());
        mserver.invoke(deployer, "manageApp",
                       new Object[] {context},
                       new String[] {"org.apache.catalina.Context"});
        mserver.invoke(deployer, "removeServiced",
                       new Object [] {contextName},
                       new String [] {"java.lang.String"});
    } else {
        log.warn("Deployer not found for "+pname.getKeyProperty("host"));
        Service service = getService(pname);
        Engine engine = (Engine) service.getContainer();
        Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
        host.addChild(context);
    }

    // Return the corresponding MBean name
    return context.getObjectName().toString();

}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:65,代码来源:MBeanFactory.java

示例13: withDefaultConfig

import org.apache.catalina.startup.ContextConfig; //导入依赖的package包/类
@Override
public TomcatApplicationBuilder withDefaultConfig() {
    ContextConfig contextConfig = new ContextConfig();
    context.addLifecycleListener(contextConfig);
    return this;
}
 
开发者ID:pidster-dot-org,项目名称:embed-apache-tomcat,代码行数:7,代码来源:TomcatApplicationBuilderImpl.java


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