use of org.apache.catalina.core.StandardHost in project tomee by apache.
the class TomEEUndeployTest method tomcatLifecycle.
@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"));
// not done in embedded but that's the way autodeploy works in normal tomcat
final HostConfig listener = new HostConfig();
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);
}
use of org.apache.catalina.core.StandardHost in project tomee by apache.
the class OpenEJBListener method tryToFindAndExtractWar.
private static File tryToFindAndExtractWar(final StandardServer source) {
if (System.getProperties().containsKey("openejb.war")) {
return new File(System.getProperty("openejb.war"));
}
for (final Service service : source.findServices()) {
final Container container = service.getContainer();
if (container instanceof StandardEngine) {
final StandardEngine engine = (StandardEngine) container;
for (final Container child : engine.findChildren()) {
if (child instanceof StandardHost) {
final StandardHost host = (StandardHost) child;
final File base = hostDir(System.getProperty("catalina.base"), host.getAppBase());
final File[] files = base.listFiles();
if (files != null) {
for (final File file : files) {
if (isTomEEWar(file)) {
return file;
}
}
}
}
}
}
}
return null;
}
use of org.apache.catalina.core.StandardHost in project tomee by apache.
the class OpenEJBListener method findOpenEjbWar.
private static File findOpenEjbWar() {
// in Tomcat 5.5 the OpenEjb war is in the server/webapps director
final String catalinaBase = System.getProperty("catalina.base");
final File serverWebapps = new File(catalinaBase, "server/webapps");
File openEjbWar = findOpenEjbWar(serverWebapps);
if (openEjbWar != null) {
return openEjbWar;
}
try {
// scan all hosts directories
for (final Service service : TomcatHelper.getServer().findServices()) {
final Container container = service.getContainer();
if (container instanceof StandardEngine) {
final StandardEngine engine = (StandardEngine) container;
for (final Container child : engine.findChildren()) {
if (child instanceof StandardHost) {
final StandardHost host = (StandardHost) child;
final File hostDir = hostDir(catalinaBase, host.getAppBase());
openEjbWar = findOpenEjbWar(hostDir);
if (openEjbWar != null) {
return openEjbWar;
} else {
return findOpenEjbWar(host);
}
}
}
}
}
} catch (final Exception e) {
LOGGER.log(Level.WARNING, "OpenEJBListener.findOpenEjbWar: " + e.getMessage());
}
return null;
}
use of org.apache.catalina.core.StandardHost in project tomee by apache.
the class GlobalListenerSupport method engineRemoved.
/**
* Engine is removed.
*
* @param engine tomcat engine
*/
private void engineRemoved(final StandardEngine engine) {
for (final Container child : engine.findChildren()) {
if (child instanceof StandardHost) {
final StandardHost host = (StandardHost) child;
hostRemoved(host);
}
}
}
use of org.apache.catalina.core.StandardHost in project tomee by apache.
the class GlobalListenerSupport method engineAdded.
/**
* Engine is added.
*
* @param engine tomcat engine
*/
private void engineAdded(final StandardEngine engine) {
addContextListener(engine);
for (final Container child : engine.findChildren()) {
if (child instanceof StandardHost) {
final StandardHost host = (StandardHost) child;
hostAdded(host);
}
}
}
Aggregations