本文整理汇总了Java中org.apache.catalina.core.StandardHost.addLifecycleListener方法的典型用法代码示例。如果您正苦于以下问题:Java StandardHost.addLifecycleListener方法的具体用法?Java StandardHost.addLifecycleListener怎么用?Java StandardHost.addLifecycleListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.catalina.core.StandardHost
的用法示例。
在下文中一共展示了StandardHost.addLifecycleListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: justAContextStop
import org.apache.catalina.core.StandardHost; //导入方法依赖的package包/类
@Test
public void justAContextStop() throws Exception {
container.start();
assertEquals(0, webapps().length);
final StandardHost standardHost = StandardHost.class.cast(TomcatHelper.getServer().findService("Tomcat").getContainer().findChild("localhost"));
final HostConfig listener = new HostConfig(); // not done in embedded but that's the way autodeploy works in normal tomcat
standardHost.addLifecycleListener(listener);
createWebapp(new File(WORK_DIR, "tomee/webapps/my-webapp"));
listener.lifecycleEvent(new LifecycleEvent(standardHost, Lifecycle.START_EVENT, standardHost));
assertEquals(1, webapps().length);
webapps()[0].stop();
assertEquals(1, webapps().length);
webapps()[0].start();
assertEquals(1, webapps().length);
assertEquals("test", IO.slurp(new URL("http://localhost:" + http + "/my-webapp/")));
}
示例2: createStandardHost
import org.apache.catalina.core.StandardHost; //导入方法依赖的package包/类
/**
* Create a new StandardHost.
*
* @param parent MBean Name of the associated parent component
* @param name Unique name of this Host
* @param appBase Application base directory name
* @param autoDeploy Should we auto deploy?
* @param deployOnStartup Deploy on server startup?
* @param deployXML Should we deploy Context XML config files property?
* @param unpackWARs Should we unpack WARs when auto deploying?
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardHost(String parent, String name,
String appBase,
boolean autoDeploy,
boolean deployOnStartup,
boolean deployXML,
boolean unpackWARs)
throws Exception {
// Create a new StandardHost instance
StandardHost host = new StandardHost();
host.setName(name);
host.setAppBase(appBase);
host.setAutoDeploy(autoDeploy);
host.setDeployOnStartup(deployOnStartup);
host.setDeployXML(deployXML);
host.setUnpackWARs(unpackWARs);
// add HostConfig for active reloading
HostConfig hostConfig = new HostConfig();
host.addLifecycleListener(hostConfig);
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
Service service = getService(pname);
Engine engine = (Engine) service.getContainer();
engine.addChild(host);
// Return the corresponding MBean name
return (host.getObjectName().toString());
}
示例3: createStandardHost
import org.apache.catalina.core.StandardHost; //导入方法依赖的package包/类
/**
* Create a new StandardHost.
*
* @param parent MBean Name of the associated parent component
* @param name Unique name of this Host
* @param appBase Application base directory name
* @param autoDeploy Should we auto deploy?
* @param deployOnStartup Deploy on server startup?
* @param deployXML Should we deploy Context XML config files property?
* @param unpackWARs Should we unpack WARs when auto deploying?
* @param xmlNamespaceAware Should we turn on/off XML namespace awareness?
* @param xmlValidation Should we turn on/off XML validation?
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardHost(String parent, String name,
String appBase,
boolean autoDeploy,
boolean deployOnStartup,
boolean deployXML,
boolean unpackWARs,
boolean xmlNamespaceAware,
boolean xmlValidation)
throws Exception {
// Create a new StandardHost instance
StandardHost host = new StandardHost();
host.setName(name);
host.setAppBase(appBase);
host.setAutoDeploy(autoDeploy);
host.setDeployOnStartup(deployOnStartup);
host.setDeployXML(deployXML);
host.setUnpackWARs(unpackWARs);
host.setXmlNamespaceAware(xmlNamespaceAware);
host.setXmlValidation(xmlValidation);
// add HostConfig for active reloading
HostConfig hostConfig = new HostConfig();
host.addLifecycleListener(hostConfig);
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
Service service = getService(pname);
Engine engine = (Engine) service.getContainer();
engine.addChild(host);
// Return the corresponding MBean name
return (host.getObjectName().toString());
}
示例4: createStandardHost
import org.apache.catalina.core.StandardHost; //导入方法依赖的package包/类
/**
* Create a new StandardHost.
*
* @param parent
* MBean Name of the associated parent component
* @param name
* Unique name of this Host
* @param appBase
* Application base directory name
* @param autoDeploy
* Should we auto deploy?
* @param deployOnStartup
* Deploy on server startup?
* @param deployXML
* Should we deploy Context XML config files property?
* @param unpackWARs
* Should we unpack WARs when auto deploying?
*
* @exception Exception
* if an MBean cannot be created or registered
*/
public String createStandardHost(String parent, String name, String appBase, boolean autoDeploy,
boolean deployOnStartup, boolean deployXML, boolean unpackWARs) throws Exception {
// Create a new StandardHost instance
StandardHost host = new StandardHost();
host.setName(name);
host.setAppBase(appBase);
host.setAutoDeploy(autoDeploy);
host.setDeployOnStartup(deployOnStartup);
host.setDeployXML(deployXML);
host.setUnpackWARs(unpackWARs);
// add HostConfig for active reloading
HostConfig hostConfig = new HostConfig();
host.addLifecycleListener(hostConfig);
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
Service service = getService(pname);
Engine engine = (Engine) service.getContainer();
engine.addChild(host);
// Return the corresponding MBean name
return (host.getObjectName().toString());
}
示例5: tomcatLifecycle
import org.apache.catalina.core.StandardHost; //导入方法依赖的package包/类
@Test
public void tomcatLifecycle() throws Exception {
container.start();
assertEquals(0, webapps().length);
final StandardHost standardHost = StandardHost.class.cast(TomcatHelper.getServer().findService("Tomcat").getContainer().findChild("localhost"));
final HostConfig listener = new HostConfig(); // not done in embedded but that's the way autodeploy works in normal tomcat
standardHost.addLifecycleListener(listener);
createWebapp(new File(WORK_DIR, "tomee/webapps/my-webapp"));
listener.lifecycleEvent(new LifecycleEvent(standardHost, Lifecycle.START_EVENT, standardHost));
assertEquals(1, webapps().length);
}
示例6: hostAdded
import org.apache.catalina.core.StandardHost; //导入方法依赖的package包/类
/**
* Host is added.
*
* @param host tomcat host.
*/
private void hostAdded(final StandardHost host) {
addContextListener(host);
host.addLifecycleListener(this);
for (final Container child : host.findChildren()) {
if (child instanceof StandardContext) {
final StandardContext context = (StandardContext) child;
contextAdded(context);
}
}
}