use of io.undertow.servlet.api.DeploymentManager in project undertow by undertow-io.
the class ServletContainerImpl method removeDeployment.
@Override
public void removeDeployment(final DeploymentInfo deploymentInfo) {
final DeploymentManager deploymentManager = deployments.get(deploymentInfo.getDeploymentName());
if (deploymentManager.getState() != DeploymentManager.State.UNDEPLOYED) {
throw UndertowServletMessages.MESSAGES.canOnlyRemoveDeploymentsWhenUndeployed(deploymentManager.getState());
}
deployments.remove(deploymentInfo.getDeploymentName());
deploymentsByPath.remove(deploymentInfo.getContextPath());
}
use of io.undertow.servlet.api.DeploymentManager in project openremote by openremote.
the class WebService method addServletDeployment.
/**
* Adds a deployment to the default servlet container and returns the started handler.
*
* @param identityService Must not be null if secure deployment is used
* @param deploymentInfo The deployment to add to the default container
* @param secure If authentication/authorization should be enabled for this deployment
*/
public HttpHandler addServletDeployment(IdentityService identityService, DeploymentInfo deploymentInfo, boolean secure) {
try {
if (secure) {
if (identityService == null)
throw new IllegalStateException("No identity service found, make sure " + IdentityService.class.getName() + " is added before this service");
identityService.secureDeployment(deploymentInfo);
} else {
LOG.info("Deploying insecure web context: " + deploymentInfo.getContextPath());
}
// This will catch anything not handled by Resteasy/Servlets, such as IOExceptions "at the wrong time"
deploymentInfo.setExceptionHandler(new WebServiceExceptions.ServletUndertowExceptionHandler(devMode));
DeploymentManager manager = Servlets.defaultContainer().addDeployment(deploymentInfo);
manager.deploy();
return manager.start();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
use of io.undertow.servlet.api.DeploymentManager in project openremote by openremote.
the class AbstractHttpServerProtocol method deploy.
protected void deploy(DeploymentInfo deploymentInfo, AssetAttribute protocolConfiguration) {
LOG.info("Deploying JAX-RS deployment for: " + protocolConfiguration.getReferenceOrThrow());
DeploymentManager manager = Servlets.defaultContainer().addDeployment(deploymentInfo);
manager.deploy();
HttpHandler httpHandler;
try {
httpHandler = manager.start();
deployments.put(protocolConfiguration.getReferenceOrThrow(), new Pair<>(deploymentInfo, httpHandler));
LOG.info("Registering HTTP Server Protocol request handler '" + this.getClass().getSimpleName() + "' for request path: " + deploymentInfo.getContextPath());
webService.getRequestPathHandler().addPrefixPath(deploymentInfo.getContextPath(), httpHandler);
} catch (ServletException e) {
LOG.severe("Failed to deploy deployment: " + deploymentInfo.getDeploymentName());
}
}
use of io.undertow.servlet.api.DeploymentManager in project cxf by apache.
the class AbstractUndertowServer method run.
protected void run() {
try {
final DeploymentInfo servletBuilder = deployment().setClassLoader(AbstractUndertowServer.class.getClassLoader()).setContextPath(contextPath).setDeploymentName("sse-test").addServlets(servlet("MessageServlet", CXFNonSpringJaxrsServlet.class).addInitParam(CXFNonSpringJaxrsServlet.TRANSPORT_ID, SseHttpTransportFactory.TRANSPORT_ID).addInitParam("jaxrs.providers", JacksonJsonProvider.class.getName()).addInitParam("jaxrs.serviceClasses", BookStore.class.getName()).setAsyncSupported(true).setLoadOnStartup(1).addMapping("/rest/*"));
final DeploymentManager manager = defaultContainer().addDeployment(servletBuilder);
manager.deploy();
PathHandler path = Handlers.path(Handlers.redirect("/")).addPrefixPath("/", manager.start());
server = Undertow.builder().addHttpListener(port, "localhost").setHandler(path).build();
server.start();
} catch (final Exception ex) {
ex.printStackTrace();
fail(ex.getMessage());
}
}
Aggregations