use of org.jboss.as.web.host.WebDeploymentBuilder in project wildfly by wildfly.
the class EndpointPublisherImpl method startWebApp.
private static WebDeploymentController startWebApp(WebHost host, DeploymentUnit unit) throws Exception {
WebDeploymentBuilder deployment = new WebDeploymentBuilder();
WebDeploymentController handle;
try {
JBossWebMetaData jbwebMD = unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY);
deployment.setContextRoot(jbwebMD.getContextRoot());
ServerConfigService config = (ServerConfigService) unit.getServiceRegistry().getService(WSServices.CONFIG_SERVICE).getService();
File docBase = new File(config.getValue().getServerTempDir(), jbwebMD.getContextRoot());
if (!docBase.exists()) {
docBase.mkdirs();
}
deployment.setDocumentRoot(docBase);
deployment.setClassLoader(unit.getAttachment(WSAttachmentKeys.CLASSLOADER_KEY));
deployment.addAllowedRequestPredicate(new AllowWSRequestPredicate());
addServlets(jbwebMD, deployment);
handle = host.addWebDeployment(deployment);
handle.create();
} catch (Exception e) {
throw WSLogger.ROOT_LOGGER.createContextPhaseFailed(e);
}
try {
handle.start();
} catch (Exception e) {
throw WSLogger.ROOT_LOGGER.startContextPhaseFailed(e);
}
return handle;
}
use of org.jboss.as.web.host.WebDeploymentBuilder in project wildfly by wildfly.
the class WebAppController method startWebApp.
private WebDeploymentController startWebApp(WebHost host) throws Exception {
WebDeploymentBuilder builder = new WebDeploymentBuilder();
WebDeploymentController deployment;
try {
builder.setContextRoot(contextRoot);
File docBase = new File(serverTempDir, contextRoot);
if (!docBase.exists()) {
docBase.mkdirs();
}
builder.setDocumentRoot(docBase);
builder.setClassLoader(classloader);
final int j = servletClass.indexOf(".");
final String servletName = j < 0 ? servletClass : servletClass.substring(j + 1);
final Class<?> clazz = classloader.loadClass(servletClass);
ServletBuilder servlet = new ServletBuilder();
servlet.setServletName(servletName);
servlet.setServlet((Servlet) clazz.newInstance());
servlet.setServletClass(clazz);
servlet.addUrlMapping(urlPattern);
builder.addServlet(servlet);
deployment = host.addWebDeployment(builder);
deployment.create();
} catch (Exception e) {
throw WSLogger.ROOT_LOGGER.createContextPhaseFailed(e);
}
try {
deployment.start();
} catch (Exception e) {
throw WSLogger.ROOT_LOGGER.startContextPhaseFailed(e);
}
return deployment;
}
Aggregations