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


Java StandardHost类代码示例

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


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

示例1: doTestUnpackWAR

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
private void doTestUnpackWAR(boolean unpackWARs, boolean unpackWAR,
        boolean external, boolean resultDir) throws Exception {

    Tomcat tomcat = getTomcatInstance();
    StandardHost host = (StandardHost) tomcat.getHost();

    host.setUnpackWARs(unpackWARs);

    tomcat.start();

    File war;
    if (unpackWAR) {
        war = createWar(WAR_XML_UNPACKWAR_TRUE_SOURCE, !external);
    } else {
        war = createWar(WAR_XML_UNPACKWAR_FALSE_SOURCE, !external);
    }
    if (external) {
        createXmlInConfigBaseForExternal(war);
    }

    host.backgroundProcess();

    File dir = new File(host.getAppBase(), APP_NAME.getBaseName());
    Assert.assertEquals(
            Boolean.valueOf(resultDir), Boolean.valueOf(dir.isDirectory()));
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:27,代码来源:TestHostConfigAutomaticDeployment.java

示例2: mbeansAvailableAfterBinder

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
@Test
void mbeansAvailableAfterBinder() throws LifecycleException, InterruptedException {
    TomcatMetrics.monitor(registry, null);

    CountDownLatch latch = new CountDownLatch(1);
    registry.config().onMeterAdded(m -> {
        if(m.getId().getName().equals("tomcat.global.received"))
            latch.countDown();
    });

    Tomcat server = new Tomcat();
    try {
        StandardHost host = new StandardHost();
        host.setName("localhost");
        server.setHost(host);
        server.setPort(61000);
        server.start();

        assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();

        assertThat(registry.find("tomcat.global.received").functionCounter()).isNotNull();
    } finally {
        server.stop();
        server.destroy();
    }
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:27,代码来源:TomcatMetricsTest.java

示例3: mbeansAvailableBeforeBinder

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
@Test
void mbeansAvailableBeforeBinder() throws LifecycleException {
    Tomcat server = new Tomcat();
    try {
        StandardHost host = new StandardHost();
        host.setName("localhost");
        server.setHost(host);
        server.setPort(61000);
        server.start();

        TomcatMetrics.monitor(registry, null);
        assertThat(registry.find("tomcat.global.received").functionCounter()).isNotNull();
    } finally {
        server.stop();
        server.destroy();
    }
}
 
开发者ID:micrometer-metrics,项目名称:micrometer,代码行数:18,代码来源:TomcatMetricsTest.java

示例4: testBug57425

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
@Test
public void testBug57425() throws LifecycleException, IOException {
    Tomcat tomcat = getTomcatInstance();
    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        ((StandardHost) host).setContextClass(ReplicatedContext.class.getName());
    }

    File root = new File("test/webapp-3.0");
    Context context = tomcat.addWebapp(host, "", root.getAbsolutePath());

    Tomcat.addServlet(context, "test", new AccessContextServlet());
    context.addServletMapping("/access", "test");

    tomcat.start();

    ByteChunk result = getUrl("http://localhost:" + getPort() + "/access");

    Assert.assertEquals("OK", result.toString());

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

示例5: testGetBrokenContextPerAddWepapp

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
@Test
public void testGetBrokenContextPerAddWepapp() {
    Tomcat tomcat = getTomcatInstance();
    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        ((StandardHost) host).setContextClass("InvalidContextClassName");
    }

    try {
        File appFile = new File("test/deployment/context.war");
        tomcat.addWebapp(null, "/test", appFile.getAbsolutePath());
        fail();
    } catch (IllegalArgumentException e) {
        // OK
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:TestTomcat.java

示例6: testGetCustomContextPerAddWebappWithNullHost

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
@Test
public void testGetCustomContextPerAddWebappWithNullHost() {
    Tomcat tomcat = getTomcatInstance();
    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        ((StandardHost) host).setContextClass(ReplicatedContext.class
                .getName());
    }

    File appFile = new File("test/deployment/context.war");
    Context context = tomcat.addWebapp(null, "/test",
            appFile.getAbsolutePath());

    assertEquals(ReplicatedContext.class.getName(), context.getClass()
            .getName());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:TestTomcat.java

示例7: testGetCustomContextPerAddWebappWithHost

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
@Test
public void testGetCustomContextPerAddWebappWithHost() {
    Tomcat tomcat = getTomcatInstance();
    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        ((StandardHost) host).setContextClass(ReplicatedContext.class
                .getName());
    }

    File appFile = new File("test/deployment/context.war");
    Context context = tomcat.addWebapp(host, "/test",
            appFile.getAbsolutePath());

    assertEquals(ReplicatedContext.class.getName(), context.getClass()
            .getName());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:TestTomcat.java

示例8: testGetBrokenContextPerAddContext

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
@Test
public void testGetBrokenContextPerAddContext() {
    Tomcat tomcat = getTomcatInstance();
    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        ((StandardHost) host).setContextClass("InvalidContextClassName");
    }

    // No file system docBase required
    try {
        tomcat.addContext(null, "", null);
        fail();
    } catch (IllegalArgumentException e) {
        // OK
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:TestTomcat.java

示例9: testBrokenAppWithAntiLocking

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
private void testBrokenAppWithAntiLocking(boolean unpackWARs)
        throws Exception {

    Tomcat tomcat = getTomcatInstance();
    StandardHost host = (StandardHost) tomcat.getHost();

    host.setUnpackWARs(unpackWARs);

    File war = createWar(WAR_BROKEN_SOURCE, false);
    createXmlInConfigBaseForExternal(war, true);

    File dir = new File(getAppBaseFile(host), APP_NAME.getBaseName());

    tomcat.start();

    // Simulate deploy on start-up
    tomcat.getHost().backgroundProcess();

    Assert.assertTrue(war.isFile());
    if (unpackWARs) {
        Assert.assertTrue(dir.isDirectory());
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:24,代码来源:TestHostConfigAutomaticDeployment.java

示例10: testSetContextClassName

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
@Test
public void testSetContextClassName() throws Exception {

    Tomcat tomcat = getTomcatInstance();

    Host host = tomcat.getHost();
    if (host instanceof StandardHost) {
        StandardHost standardHost = (StandardHost) host;
        standardHost.setContextClass(TesterContext.class.getName());
    }

    // Copy the WAR file
    File war = new File(getAppBaseFile(host),
            APP_NAME.getBaseName() + ".war");
    copy(WAR_XML_SOURCE, war);

    // Deploy the copied war
    tomcat.start();
    host.backgroundProcess();

    // Check the Context class
    Context ctxt = (Context) host.findChild(APP_NAME.getName());

    Assert.assertTrue(ctxt instanceof TesterContext);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:26,代码来源:TestHostConfigAutomaticDeployment.java

示例11: addWebapp

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
public StandardContext addWebapp(StandardHost host, 
                                 String url, String path) 
       throws ServletException {
    silence(url);

    StandardContext ctx = new StandardContext();
    ctx.setPath( url );
    ctx.setDocBase(path);
    if (defaultRealm == null) {
        initSimpleAuth();
    }
    ctx.setRealm(defaultRealm);
    initWebappDefaults(ctx);
    
    ContextConfig ctxCfg = new ContextConfig();
    ctx.addLifecycleListener( ctxCfg );
    // prevent it from looking ( if it finds one - it'll have dup error )
    ctxCfg.setDefaultWebXml("org/apache/catalin/startup/NO_DEFAULT_XML");
    
    if (host == null) {
        host = getHost();
    }
    host.addChild(ctx);

    return ctx;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:Tomcat.java

示例12: getValves

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
/**
 * Return the MBean Names of the Valves assoicated with this Host
 *
 * @exception Exception if an MBean cannot be created or registered
 */
public String [] getValves()
    throws Exception {

    Registry registry = MBeanUtils.createRegistry();
    StandardHost host = (StandardHost) this.resource;
    String mname = MBeanUtils.createManagedName(host);
    ManagedBean managed = registry.findManagedBean(mname);
    String domain = null;
    if (managed != null) {
        domain = managed.getDomain();
    }
    if (domain == null)
        domain = mserver.getDefaultDomain();
    Valve [] valves = host.getValves();
    String [] mbeanNames = new String[valves.length];
    for (int i = 0; i < valves.length; i++) {
        mbeanNames[i] =
            MBeanUtils.createObjectName(domain, valves[i]).toString();
    }

    return mbeanNames;

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

示例13: removeHost

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
/**
 * Remove an existing Host.
 *
 * @param name MBean Name of the comonent to remove
 *
 * @exception Exception if a component cannot be removed
 */
public void removeHost(String name) throws Exception {

    // Acquire a reference to the component to be removed
    ObjectName oname = new ObjectName(name);
    String hostName = oname.getKeyProperty("host");
    Service service = getService(oname);
    Engine engine = (Engine) service.getContainer();
    Host host = (Host) engine.findChild(hostName);

    // Remove this component from its parent component
    if(host!=null) {
        if(host instanceof StandardHost)
            ((StandardHost)host).destroy();
        else
            engine.removeChild(host);
    }

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

示例14: findleaks

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
/**
 * Find potential memory leaks caused by web application reload.
 */
protected void findleaks(boolean statusLine, PrintWriter writer, StringManager smClient) {

	if (!(host instanceof StandardHost)) {
		writer.println(smClient.getString("managerServlet.findleaksFail"));
		return;
	}

	String[] results = ((StandardHost) host).findReloadedContextMemoryLeaks();

	if (results.length > 0) {
		if (statusLine) {
			writer.println(smClient.getString("managerServlet.findleaksList"));
		}
		for (String result : results) {
			if ("".equals(result)) {
				result = "/";
			}
			writer.println(result);
		}
	} else if (statusLine) {
		writer.println(smClient.getString("managerServlet.findleaksNone"));
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:27,代码来源:ManagerServlet.java

示例15: getPort

import org.apache.catalina.core.StandardHost; //导入依赖的package包/类
public static int getPort(Host h) {
	int port = -1;
	StandardHost host = (StandardHost) h;
	CatalinaUtil.host = (StandardHost) h;

	StandardEngine se = (StandardEngine) host.getParent();
	StandardService ss = (StandardService) se.getService();

	Connector[] cs = ss.findConnectors();
	for (Connector c : cs) {

		if (c.getProtocolHandlerClassName().contains("Http11Protocol"))
			port = c.getPort();
	}
	return port;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:17,代码来源:CatalinaUtil.java


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