use of org.apache.catalina.core.StandardHost in project tomee by apache.
the class TomEEUndeployTest method justAContextStop.
@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"));
// 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);
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/")));
}
use of org.apache.catalina.core.StandardHost in project tomee by apache.
the class WebappDeployer method check.
private void check() {
final StandardServer server = TomcatHelper.getServer();
for (final Service service : server.findServices()) {
if (service.getContainer() instanceof Engine) {
final Engine engine = (Engine) service.getContainer();
for (final Container engineChild : engine.findChildren()) {
if (engineChild instanceof StandardHost) {
final StandardHost host = (StandardHost) engineChild;
webappBuilder.checkHost(host);
}
}
}
}
}
use of org.apache.catalina.core.StandardHost in project tomcat by apache.
the class StoreContextAppender method isPrintValue.
/**
* Print Context Values. <ul><li> Special handling to default workDir.
* </li><li> Don't save path at external context.xml </li><li> Don't
* generate docBase for host.appBase webapps <LI></ul>
*
* @see org.apache.catalina.storeconfig.StoreAppender#isPrintValue(java.lang.Object,
* java.lang.Object, java.lang.String,
* org.apache.catalina.storeconfig.StoreDescription)
*/
@Override
public boolean isPrintValue(Object bean, Object bean2, String attrName, StoreDescription desc) {
boolean isPrint = super.isPrintValue(bean, bean2, attrName, desc);
if (isPrint) {
StandardContext context = ((StandardContext) bean);
if ("workDir".equals(attrName)) {
String defaultWorkDir = getDefaultWorkDir(context);
isPrint = !defaultWorkDir.equals(context.getWorkDir());
} else if ("path".equals(attrName)) {
isPrint = desc.isStoreSeparate() && desc.isExternalAllowed() && context.getConfigFile() == null;
} else if ("docBase".equals(attrName)) {
Container host = context.getParent();
if (host instanceof StandardHost) {
File appBase = getAppBase(((StandardHost) host));
File docBase = getDocBase(context, appBase);
isPrint = !appBase.equals(docBase.getParentFile());
}
}
}
return isPrint;
}
use of org.apache.catalina.core.StandardHost in project tomcat by apache.
the class StoreContextAppender method getDefaultWorkDir.
/**
* Make default Work Dir.
*
* @param context The context
* @return The default working directory for the context.
*/
protected String getDefaultWorkDir(StandardContext context) {
String defaultWorkDir = null;
String contextWorkDir = context.getName();
if (contextWorkDir.length() == 0)
contextWorkDir = "_";
if (contextWorkDir.startsWith("/"))
contextWorkDir = contextWorkDir.substring(1);
Container host = context.getParent();
if (host instanceof StandardHost) {
String hostWorkDir = ((StandardHost) host).getWorkDir();
if (hostWorkDir != null) {
defaultWorkDir = hostWorkDir + File.separator + contextWorkDir;
} else {
String engineName = context.getParent().getParent().getName();
String hostName = context.getParent().getName();
defaultWorkDir = "work" + File.separator + engineName + File.separator + hostName + File.separator + contextWorkDir;
}
}
return defaultWorkDir;
}
use of org.apache.catalina.core.StandardHost in project tomcat by apache.
the class TestHandlerIntegration method testToURI.
@Test
public void testToURI() 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();
URL url = ctx.getServletContext().getResource("/index.html");
try {
url.toURI();
} catch (Exception e) {
e.printStackTrace();
Assert.fail();
}
}
Aggregations