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


Java WebappLoader类代码示例

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


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

示例1: createWebappLoader

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
/**
 * Create a new Web Application Loader.
 *
 * @param parent MBean Name of the associated parent component
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String createWebappLoader(String parent)
    throws Exception {

    // Create a new WebappLoader instance
    WebappLoader loader = new WebappLoader();

    // Add the new instance to its parent component
    ObjectName pname = new ObjectName(parent);
    ContainerBase containerBase = getParentContainerFromParent(pname);
    if (containerBase != null) {
        containerBase.setLoader(loader);
    } 
    // FIXME add Loader.getObjectName
    //ObjectName oname = loader.getObjectName();
    ObjectName oname = 
        MBeanUtils.createObjectName(pname.getDomain(), loader);
    return (oname.toString());
    
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:27,代码来源:MBeanFactory.java

示例2: isDefaultLoader

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
/**
 * Is this an instance of the default <code>Loader</code> configuration,
 * with all-default properties?
 *
 * @param loader Loader to be tested
 */
private boolean isDefaultLoader(Loader loader) {

    if (!(loader instanceof WebappLoader)) {
        return (false);
    }
    WebappLoader wloader = (WebappLoader) loader;
    if ((wloader.getCheckInterval() != 15) ||
        (wloader.getDebug() != 0) ||
        (wloader.getDelegate() != false) ||
        !wloader.getLoaderClass().equals
         ("org.apache.catalina.loader.WebappClassLoader")) {
        return (false);
    }
    return (true);

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

示例3: createWebappLoader

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
/**
 * Create a new Web Application Loader.
 *
 * @param parent
 *            MBean Name of the associated parent component
 *
 * @exception Exception
 *                if an MBean cannot be created or registered
 */
public String createWebappLoader(String parent) throws Exception {

	// Create a new WebappLoader instance
	WebappLoader loader = new WebappLoader();

	// Add the new instance to its parent component
	ObjectName pname = new ObjectName(parent);
	ContainerBase containerBase = getParentContainerFromParent(pname);
	if (containerBase != null) {
		containerBase.setLoader(loader);
	}
	// FIXME add Loader.getObjectName
	// ObjectName oname = loader.getObjectName();
	ObjectName oname = MBeanUtils.createObjectName(pname.getDomain(), loader);
	return (oname.toString());

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

示例4: startPeopleService

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
public void startPeopleService() throws Exception {
    final File base = createBaseDirectory();
    log.info("Using base folder: " + base.getAbsolutePath());

    final Tomcat tomcat = new Tomcat();
    tomcat.setPort(8080);
    tomcat.setBaseDir(base.getAbsolutePath());

    Context context = tomcat.addContext("/", base.getAbsolutePath());
    Tomcat.addServlet(context, "CXFServlet", new CXFServlet());

    context.addServletMapping("/rest/*", "CXFServlet");
    context.addApplicationListener(ContextLoaderListener.class.getName());
    context.setLoader(new WebappLoader(Thread.currentThread().getContextClassLoader()));

    context.addParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
    context.addParameter("contextConfigLocation", AppConfig.class.getName());

    tomcat.start();
    tomcat.getServer().await();
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:22,代码来源:Starter.java

示例5: main

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
public static void main(final String[] args) throws Exception {
    final File base = createBaseDirectory();
    log.info("Using base folder: " + base.getAbsolutePath());

    final Tomcat tomcat = new Tomcat();
    tomcat.setPort(8080);
    tomcat.setBaseDir( base.getAbsolutePath() );

    Context context = tomcat.addContext( "/", base.getAbsolutePath() );
    Tomcat.addServlet( context, "CXFServlet", new CXFServlet() );

    context.addServletMapping( "/rest/*", "CXFServlet" );
    context.addApplicationListener( ContextLoaderListener.class.getName() );
    context.setLoader( new WebappLoader( Thread.currentThread().getContextClassLoader() ) );

    context.addParameter( "contextClass", AnnotationConfigWebApplicationContext.class.getName() );
    context.addParameter( "contextConfigLocation", MusicConfig.class.getName() );

    tomcat.start();
    tomcat.getServer().await();
}
 
开发者ID:wso2,项目名称:product-ei,代码行数:22,代码来源:Server.java

示例6: setUp

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    this.manager = mock( RedisSessionManager.class );
    this.request = mock( Request.class, withSettings().useConstructor() ); // useConstructor to instantiate fields
    this.response = mock( Response.class );

    final Context contextContainer = mock(Context.class);
    this.hostContainer = mock(Host.class);

    when(contextContainer.getParent()).thenReturn(hostContainer);
    when(contextContainer.getPath()).thenReturn("/");

    when(request.getRequestURI()).thenReturn( "/requestURI"); // override for tests
    when(request.getMethod()).thenReturn("GET");
    when(request.getQueryString()).thenReturn(null);
    when(request.getContext()).thenReturn(contextContainer);

    doCallRealMethod().when(request).setNote(Mockito.anyString(), Mockito.anyObject());
    doCallRealMethod().when(request).removeNote(Mockito.anyString());
    when(request.getNote(Mockito.anyString())).thenCallRealMethod();
    
    when(contextContainer.getLoader()).thenReturn(new WebappLoader(Thread.currentThread().getContextClassLoader()));
}
 
开发者ID:chexagon,项目名称:redis-session-manager,代码行数:24,代码来源:RedisSessionRequestValveTest.java

示例7: after

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
    // target should be an instance of WebappLoader.
    if (target instanceof WebappLoader) {
        WebappLoader webappLoader = (WebappLoader)target;
        try {
            String contextKey = extractContextKey(webappLoader);
            List<String> loadedJarNames = extractLibJars(webappLoader);
            dispatchLibJars(contextKey, loadedJarNames);
        } catch (Exception e) {
            if (logger.isWarnEnabled()) {
                logger.warn(e.getMessage(), e);
            }
        }
    } else {
        logger.warn("Webapp loader is not an instance of org.apache.catalina.loader.WebappLoader. Found [{}]", target.getClass().toString());
    }
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:19,代码来源:WebappLoaderStartInterceptor.java

示例8: extractContextKey

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
private String extractContextKey(WebappLoader webappLoader) {
    final String defaultContextName = "";
    try {
        Container container = extractContext(webappLoader);
        // WebappLoader's associated Container should be a Context.
        if (container instanceof Context) {
            Context context = (Context)container;
            String contextName = context.getName();
            Host host = (Host)container.getParent();
            Engine engine = (Engine)host.getParent();
            StringBuilder sb = new StringBuilder();
            sb.append(engine.getName()).append("/").append(host.getName());
            if (!contextName.startsWith("/")) {
                sb.append('/');
            }
            sb.append(contextName);
            return sb.toString();
        }
    } catch (Exception e) {
        // Same action for any and all exceptions.
        logger.warn("Error extracting context name.", e);
    }
    return defaultContextName;
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:25,代码来源:WebappLoaderStartInterceptor.java

示例9: extractContext

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
private Container extractContext(WebappLoader webappLoader) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
    Method m;
    try {
        // Tomcat 6, 7 - org.apache.catalina.loader.getContainer() 
        m = webappLoader.getClass().getDeclaredMethod("getContainer");
    } catch (NoSuchMethodException e1) {
        try {
            // Tomcat 8 - org.apache.catalina.loader.getContainer()
            m = webappLoader.getClass().getDeclaredMethod("getContext");
        } catch (NoSuchMethodException e2) {
            logger.warn("Webapp loader does not have access to its container.");
            return null;
        }
    }
    Object container = m.invoke(webappLoader);
    if (container instanceof Container) {
        return (Container)container;
    }
    return null;
}
 
开发者ID:masonmei,项目名称:apm-agent,代码行数:21,代码来源:WebappLoaderStartInterceptor.java

示例10: executeApp

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
@Override
public void executeApp() throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context =
            tomcat.addWebapp("", new File("src/test/resources").getAbsolutePath());

    WebappLoader webappLoader = new WebappLoader(RenderJsfInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    tomcat.start();

    doTest(port);

    tomcat.stop();
    tomcat.destroy();
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:20,代码来源:JsfRenderIT.java

示例11: executeApp

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
@Override
public void executeApp() throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context =
            tomcat.addWebapp("", new File("src/test/resources").getAbsolutePath());

    WebappLoader webappLoader = new WebappLoader(RenderInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    // this is needed in order for Tomcat to find annotated classes
    VirtualDirContext resources = new VirtualDirContext();
    resources.setExtraResourcePaths("/WEB-INF/classes=target/test-classes");
    context.setResources(resources);

    tomcat.start();

    doTest(port);

    tomcat.stop();
    tomcat.destroy();
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:25,代码来源:GrailsIT.java

示例12: executeApp

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
@Override
public void executeApp() throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context =
            tomcat.addWebapp(contextPath, new File("src/test/resources").getAbsolutePath());

    WebappLoader webappLoader =
            new WebappLoader(InvokeServletInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    // this is needed in order for Tomcat to find annotated servlet
    VirtualDirContext resources = new VirtualDirContext();
    resources.setExtraResourcePaths("/WEB-INF/classes=target/test-classes");
    context.setResources(resources);

    tomcat.start();

    doTest(port);

    tomcat.stop();
    tomcat.destroy();
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:26,代码来源:InvokeServletInTomcat.java

示例13: executeApp

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
@Override
public void executeApp() throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context =
            tomcat.addWebapp("", new File("src/test/resources/struts1").getAbsolutePath());

    WebappLoader webappLoader =
            new WebappLoader(ExecuteActionInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    tomcat.start();

    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode = asyncHttpClient.prepareGet("http://localhost:" + port + "/hello.do")
            .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }

    tomcat.stop();
    tomcat.destroy();
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:27,代码来源:StrutsOneIT.java

示例14: executeApp

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
public void executeApp(String webapp, String contextPath, String url) throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context = tomcat.addWebapp(contextPath,
            new File("src/test/resources/" + webapp).getAbsolutePath());

    WebappLoader webappLoader =
            new WebappLoader(InvokeJaxrsResourceInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    tomcat.start();
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode = asyncHttpClient.prepareGet("http://localhost:" + port + contextPath + url)
            .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }

    tomcat.stop();
    tomcat.destroy();
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:25,代码来源:InvokeJaxrsResourceInTomcat.java

示例15: executeApp

import org.apache.catalina.loader.WebappLoader; //导入依赖的package包/类
public void executeApp(String webapp, String contextPath, String url) throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context = tomcat.addWebapp(contextPath,
            new File("src/test/resources/" + webapp).getAbsolutePath());

    WebappLoader webappLoader =
            new WebappLoader(InvokeJaxwsWebServiceInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    tomcat.start();

    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setServiceClass(ForBothHelloAndRootService.class);
    factory.setAddress("http://localhost:" + port + contextPath + url);
    ForBothHelloAndRootService client = (ForBothHelloAndRootService) factory.create();
    client.echo("abc");

    checkForRequestThreads(webappLoader);
    tomcat.stop();
    tomcat.destroy();
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:25,代码来源:InvokeJaxwsWebServiceInTomcat.java


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