use of org.apache.catalina.core.StandardHost in project tomcat by apache.
the class TestAbstractArchiveResource method testNestedJarGetURL.
@Test
public void testNestedJarGetURL() throws Exception {
Tomcat tomcat = getTomcatInstance();
File docBase = new File("test/webresources/war-url-connection.war");
Context ctx = tomcat.addWebapp("/test", docBase.getAbsolutePath());
skipTldsForResourceJars(ctx);
((StandardHost) tomcat.getHost()).setUnpackWARs(false);
tomcat.start();
WebResource webResource = ctx.getResources().getClassLoaderResource("/META-INF/resources/index.html");
StringBuilder expectedURL = new StringBuilder("jar:war:");
expectedURL.append(docBase.getAbsoluteFile().toURI().toURL().toString());
expectedURL.append("*/WEB-INF/lib/test.jar!/META-INF/resources/index.html");
Assert.assertEquals(expectedURL.toString(), webResource.getURL().toString());
}
use of org.apache.catalina.core.StandardHost in project pinpoint by naver.
the class StandardHostValveInvokeModifierTest method setUp.
/**
* Sets the up.
*
* @throws Exception the exception
*/
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
initMockRequest();
// StandardHost's default constructor sets StandardHostValve as the first item in the pipeline.
host = new StandardHost();
}
use of org.apache.catalina.core.StandardHost in project pinpoint by naver.
the class StandardHostValveInvokeModifierTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
initMockRequest();
// StandardHost's default constructor sets StandardHostValve as the first item in the pipeline.
host = new StandardHost();
}
use of org.apache.catalina.core.StandardHost in project tomee by apache.
the class GlobalListenerSupport method lifecycleEvent.
/**
* {@inheritDoc}
*/
public void lifecycleEvent(final LifecycleEvent event) {
final Object source = event.getSource();
if (source instanceof StandardContext) {
final StandardContext standardContext = (StandardContext) source;
if (standardContext instanceof IgnoredStandardContext) {
return;
}
final String type = event.getType();
switch(// better than if cause it prevent duplicates
type) {
case INIT_EVENT:
case Lifecycle.BEFORE_INIT_EVENT:
contextListener.init(standardContext);
break;
case Lifecycle.BEFORE_START_EVENT:
contextListener.beforeStart(standardContext);
break;
case Lifecycle.START_EVENT:
standardContext.addParameter("openejb.start.late", "true");
contextListener.start(standardContext);
break;
case Lifecycle.AFTER_START_EVENT:
contextListener.afterStart(standardContext);
standardContext.removeParameter("openejb.start.late");
break;
case Lifecycle.BEFORE_STOP_EVENT:
contextListener.beforeStop(standardContext);
break;
case Lifecycle.STOP_EVENT:
contextListener.stop(standardContext);
break;
case Lifecycle.AFTER_STOP_EVENT:
contextListener.afterStop(standardContext);
break;
case DESTROY_EVENT:
case Lifecycle.AFTER_DESTROY_EVENT:
contextListener.destroy(standardContext);
break;
case Lifecycle.CONFIGURE_START_EVENT:
contextListener.configureStart(event, standardContext);
break;
default:
}
} else if (StandardHost.class.isInstance(source)) {
final StandardHost standardHost = (StandardHost) source;
final String type = event.getType();
if (Lifecycle.PERIODIC_EVENT.equals(type)) {
contextListener.checkHost(standardHost);
} else if (Lifecycle.AFTER_START_EVENT.equals(type) && REMOTE_SUPPORT) {
final TomEERemoteWebapp child = new TomEERemoteWebapp();
if (!hasChild(standardHost, child.getName())) {
standardHost.addChild(child);
}
// else old tomee webapp surely
}
} else if (StandardServer.class.isInstance(source)) {
final StandardServer standardServer = (StandardServer) source;
final String type = event.getType();
if (Lifecycle.START_EVENT.equals(type)) {
contextListener.start(standardServer);
}
if (Lifecycle.BEFORE_STOP_EVENT.equals(type)) {
TomcatHelper.setStopping(true);
final TomEEClusterListener tomEEClusterListener = SystemInstance.get().getComponent(TomEEClusterListener.class);
if (tomEEClusterListener != null) {
TomEEClusterListener.stop();
}
}
if (Lifecycle.AFTER_STOP_EVENT.equals(type)) {
contextListener.afterStop(standardServer);
}
}
// Notify
// here this way we are sure we get it even in embedded mode. TODO: we miss then few boot events, is it an issue.
SystemInstance.get().fireEvent(event);
}
use of org.apache.catalina.core.StandardHost in project tomee by apache.
the class Contexts method oldRealWarPath.
@Deprecated
private static File oldRealWarPath(final Context standardContext) {
String doc = standardContext.getDocBase();
// handle ROOT case
if (doc == null || doc.length() == 0) {
doc = "ROOT";
}
File war = new File(doc);
if (war.exists()) {
return war;
}
final StandardHost host = (StandardHost) standardContext.getParent();
final String base = host.getAppBase();
war = new File(base, doc);
if (war.exists()) {
return war;
}
war = new File(new File(System.getProperty("catalina.home"), base), doc);
if (war.exists()) {
return war;
}
// shouldn't occur
return new File(new File(System.getProperty("catalina.base"), base), doc);
}
Aggregations