use of io.undertow.servlet.api.DeploymentManager in project undertow by undertow-io.
the class JSRWebSocketServer method main.
public static void main(final String[] args) {
PathHandler path = Handlers.path();
Undertow server = Undertow.builder().addHttpListener(8080, "localhost").setHandler(path).build();
server.start();
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentInfo builder = new DeploymentInfo().setClassLoader(JSRWebSocketServer.class.getClassLoader()).setContextPath("/").addWelcomePage("index.html").setResourceManager(new ClassPathResourceManager(JSRWebSocketServer.class.getClassLoader(), JSRWebSocketServer.class.getPackage())).addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo().setBuffers(new DefaultByteBufferPool(true, 100)).addEndpoint(JsrChatWebSocketEndpoint.class)).setDeploymentName("chat.war");
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
try {
path.addPrefixPath("/", manager.start());
} catch (ServletException e) {
throw new RuntimeException(e);
}
}
use of io.undertow.servlet.api.DeploymentManager in project undertow by undertow-io.
the class ServletContainerImpl method getDeploymentByPath.
@Override
public DeploymentManager getDeploymentByPath(final String path) {
DeploymentManager exact = deploymentsByPath.get(path.isEmpty() ? "/" : path);
if (exact != null) {
return exact;
}
int length = path.length();
int pos = length;
while (pos > 1) {
--pos;
if (path.charAt(pos) == '/') {
String part = path.substring(0, pos);
DeploymentManager deployment = deploymentsByPath.get(part);
if (deployment != null) {
return deployment;
}
}
}
return deploymentsByPath.get("/");
}
use of io.undertow.servlet.api.DeploymentManager in project undertow by undertow-io.
the class ServletContainerImpl method addDeployment.
@Override
public DeploymentManager addDeployment(final DeploymentInfo deployment) {
final DeploymentInfo dep = deployment.clone();
DeploymentManager deploymentManager = new DeploymentManagerImpl(dep, this);
deployments.put(dep.getDeploymentName(), deploymentManager);
deploymentsByPath.put(dep.getContextPath(), deploymentManager);
return deploymentManager;
}
use of io.undertow.servlet.api.DeploymentManager in project wildfly by wildfly.
the class AbstractRTSService method deployServlet.
protected void deployServlet(final DeploymentInfo deploymentInfo) {
DeploymentManager manager = ServletContainer.Factory.newInstance().addDeployment(deploymentInfo);
manager.deploy();
deployment = manager.getDeployment();
try {
injectedHost.getValue().registerDeployment(deployment, manager.start());
} catch (ServletException e) {
RTSLogger.ROOT_LOGGER.warn(e.getMessage(), e);
deployment = null;
}
}
use of io.undertow.servlet.api.DeploymentManager in project indy by Commonjava.
the class JaxRsBooter method deploy.
@Override
public boolean deploy() {
boolean started;
final IndyDeployment indyDeployment = container.instance().select(IndyDeployment.class).get();
final DeploymentInfo di = indyDeployment.getDeployment(bootOptions.getContextPath()).setContextPath("/");
final DeploymentManager dm = Servlets.defaultContainer().addDeployment(di);
dm.deploy();
status = new BootStatus();
try {
Integer port = bootOptions.getPort();
if (port < 1) {
System.out.println("Looking for open port...");
final ThreadLocal<ServletException> errorHolder = new ThreadLocal<>();
ThreadLocal<Integer> usingPort = new ThreadLocal<>();
server = PortFinder.findPortFor(16, (foundPort) -> {
Undertow undertow = null;
try {
undertow = Undertow.builder().setHandler(dm.start()).addHttpListener(foundPort, bootOptions.getBind()).build();
undertow.start();
usingPort.set(foundPort);
} catch (ServletException e) {
errorHolder.set(e);
}
return undertow;
});
ServletException e = errorHolder.get();
if (e != null) {
throw e;
}
bootOptions.setPort(usingPort.get());
} else {
server = Undertow.builder().setHandler(dm.start()).addHttpListener(port, bootOptions.getBind()).build();
server.start();
}
System.out.println("Using: " + bootOptions.getPort());
status.markSuccess();
started = true;
System.out.printf("Indy listening on %s:%s\n\n", bootOptions.getBind(), bootOptions.getPort());
} catch (ServletException | RuntimeException e) {
status.markFailed(ERR_CANT_LISTEN, e);
started = false;
}
return started;
}
Aggregations