use of io.undertow.servlet.api.DeploymentManager in project cxf by apache.
the class UndertowHTTPServerEngine method buildServletContext.
private ServletContext buildServletContext(String contextName) throws ServletException {
ServletContainer servletContainer = new ServletContainerImpl();
DeploymentInfo deploymentInfo = new DeploymentInfo();
deploymentInfo.setClassLoader(Thread.currentThread().getContextClassLoader());
deploymentInfo.setDeploymentName("cxf-undertow");
deploymentInfo.setContextPath(contextName);
ServletInfo asyncServlet = new ServletInfo(ServletPathMatches.DEFAULT_SERVLET_NAME, CxfUndertowServlet.class);
deploymentInfo.addServlet(asyncServlet);
servletContainer.addDeployment(deploymentInfo);
DeploymentManager deploymentManager = servletContainer.getDeployment(deploymentInfo.getDeploymentName());
deploymentManager.deploy();
deploymentManager.start();
return deploymentManager.getDeployment().getServletContext();
}
use of io.undertow.servlet.api.DeploymentManager in project openremote by openremote.
the class AbstractHttpServerProtocol method undeploy.
protected void undeploy(AssetAttribute protocolConfiguration) {
Pair<DeploymentInfo, HttpHandler> deploymentInfoHttpHandlerPair = deployments.get(protocolConfiguration.getReferenceOrThrow());
if (deploymentInfoHttpHandlerPair == null) {
LOG.info("Deployment doesn't exist for protocol configuration: " + protocolConfiguration);
return;
}
DeploymentInfo deploymentInfo = deploymentInfoHttpHandlerPair.key;
try {
LOG.info("Un-registering HTTP Server Protocol request handler '" + this.getClass().getSimpleName() + "' for request path: " + deploymentInfo.getContextPath());
webService.getRequestPathHandler().removePrefixPath(deploymentInfo.getContextPath());
DeploymentManager manager = Servlets.defaultContainer().getDeployment(deploymentInfo.getDeploymentName());
manager.stop();
manager.undeploy();
Servlets.defaultContainer().removeDeployment(deploymentInfo);
deployments.remove(protocolConfiguration.getReferenceOrThrow());
} catch (Exception ex) {
LOG.log(Level.WARNING, "An exception occurred whilst un-deploying protocolConfiguration: " + protocolConfiguration.getReferenceOrThrow(), ex);
throw new RuntimeException(ex);
}
}
use of io.undertow.servlet.api.DeploymentManager in project openremote by openremote.
the class WebService method removeServletDeployment.
public void removeServletDeployment(DeploymentInfo deploymentInfo) {
try {
DeploymentManager manager = Servlets.defaultContainer().getDeployment(deploymentInfo.getDeploymentName());
manager.stop();
manager.undeploy();
Servlets.defaultContainer().removeDeployment(deploymentInfo);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
use of io.undertow.servlet.api.DeploymentManager in project undertow by undertow-io.
the class DeploymentUtils method setupServlet.
/**
* Sets up a simple servlet deployment with the provided servlets.
*
* This is just a convenience method for simple deployments
*
* @param servlets The servlets to add
*/
public static Deployment setupServlet(final ServletExtension servletExtension, final ServletInfo... servlets) {
final PathHandler pathHandler = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentInfo builder = new DeploymentInfo().setClassLoader(SimpleServletTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addServlets(servlets);
if (servletExtension != null) {
builder.addServletExtension(servletExtension);
}
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
try {
pathHandler.addPrefixPath(builder.getContextPath(), manager.start());
} catch (ServletException e) {
throw new RuntimeException(e);
}
DefaultServer.setRootHandler(pathHandler);
return manager.getDeployment();
}
use of io.undertow.servlet.api.DeploymentManager in project undertow by undertow-io.
the class AbstractResponseWrapperTestCase method setup.
@Before
public void setup() throws ServletException {
DeploymentInfo builder = new DeploymentInfo();
builder.setExceptionHandler(LoggingExceptionHandler.builder().add(IllegalArgumentException.class, "io.undertow", Logger.Level.DEBUG).build());
final PathHandler root = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
builder.addServlet(new ServletInfo("wrapperServlet", WrapperServlet.class).addMapping("/*"));
builder.addFilter(new FilterInfo("standard", StandardRequestWrappingFilter.class));
builder.addFilterUrlMapping("standard", "/standard", DispatcherType.REQUEST);
builder.addFilter(new FilterInfo("nonstandard", NonStandardRequestWrappingFilter.class));
builder.addFilterUrlMapping("nonstandard", "/nonstandard", DispatcherType.REQUEST);
builder.setClassIntrospecter(TestClassIntrospector.INSTANCE).setClassLoader(AbstractResponseWrapperTestCase.class.getClassLoader()).setContextPath("/servletContext").setDeploymentName("servletContext.war").setAllowNonStandardWrappers(isNonStandardAllowed());
final DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
root.addPrefixPath(builder.getContextPath(), manager.start());
DefaultServer.setRootHandler(root);
}
Aggregations