use of io.undertow.servlet.api.DeploymentInfo in project wildfly by wildfly.
the class UndertowHostTestCase method getContexts.
@Test
public void getContexts() {
Deployment deployment = mock(Deployment.class);
DeploymentInfo info = new DeploymentInfo();
String expectedPath = "";
info.setContextPath(expectedPath);
HttpHandler handler = mock(HttpHandler.class);
when(deployment.getDeploymentInfo()).thenReturn(info);
this.undertowHost.registerDeployment(deployment, handler);
Iterator<Context> result = this.host.getContexts().iterator();
assertTrue(result.hasNext());
Context context = result.next();
assertSame(this.host, context.getHost());
assertSame(expectedPath, context.getPath());
assertFalse(result.hasNext());
}
use of io.undertow.servlet.api.DeploymentInfo in project wildfly by wildfly.
the class VolatileParticipantService method deployParticipant.
private void deployParticipant() {
undeployServlet();
final Map<String, String> initialParameters = new HashMap<String, String>();
initialParameters.put("javax.ws.rs.Application", VolatileParticipantApplication.class.getName());
final DeploymentInfo participantDeploymentInfo = getDeploymentInfo(DEPLOYMENT_NAME, CONTEXT_PATH, initialParameters);
deployServlet(participantDeploymentInfo);
}
use of io.undertow.servlet.api.DeploymentInfo in project wildfly by wildfly.
the class AbstractRTSService method getDeploymentInfo.
protected DeploymentInfo getDeploymentInfo(final String name, final String contextPath, final Map<String, String> initialParameters) {
final DeploymentInfo deploymentInfo = new DeploymentInfo();
deploymentInfo.setClassLoader(ParticipantService.class.getClassLoader());
deploymentInfo.setContextPath(contextPath);
deploymentInfo.setDeploymentName(name);
deploymentInfo.addServlets(getResteasyServlet());
deploymentInfo.addListener(getResteasyListener());
deploymentInfo.addListener(getRestATListener());
for (Entry<String, String> entry : initialParameters.entrySet()) {
deploymentInfo.addInitParameter(entry.getKey(), entry.getValue());
}
return deploymentInfo;
}
use of io.undertow.servlet.api.DeploymentInfo 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;
}
use of io.undertow.servlet.api.DeploymentInfo in project indy by Commonjava.
the class IndyDeployment method getDeployment.
public DeploymentInfo getDeployment(final String contextRoot) {
final ResteasyDeployment deployment = new ResteasyDeployment();
deployment.setApplication(this);
deployment.setInjectorFactoryClass(CdiInjectorFactoryImpl.class.getName());
final ServletInfo resteasyServlet = Servlets.servlet("REST", HttpServlet30Dispatcher.class).setAsyncSupported(true).setLoadOnStartup(1).addMapping("/api*").addMapping("/api/*").addMapping("/api-docs*").addMapping("/api-docs/*").addMapping("/swagger.json").addMapping("/swagger.yaml");
final BeanConfig beanConfig = new BeanConfig();
beanConfig.setResourcePackage("org.commonjava.indy");
beanConfig.setBasePath("/");
beanConfig.setLicense("ASLv2");
beanConfig.setLicenseUrl("http://www.apache.org/licenses/LICENSE-2.0");
beanConfig.setScan(true);
beanConfig.setVersion(versioning.getApiVersion());
final FilterInfo resourceManagementFilter = Servlets.filter("Naming and Resource Management", ResourceManagementFilter.class, new ImmediateInstanceFactory<ResourceManagementFilter>(this.resourceManagementFilter));
final DeploymentInfo di = new DeploymentInfo().addListener(Servlets.listener(RequestScopeListener.class)).setContextPath(contextRoot).addServletContextAttribute(ResteasyDeployment.class.getName(), deployment).addServlet(resteasyServlet).addFilter(resourceManagementFilter).addFilterUrlMapping(resourceManagementFilter.getName(), "/api/*", DispatcherType.REQUEST).setDeploymentName("Indy").setClassLoader(ClassLoader.getSystemClassLoader()).addOuterHandlerChainWrapper(new HeaderDebugger.Wrapper());
if (deploymentProviders != null) {
DeploymentInfoUtils.mergeFromProviders(di, deploymentProviders);
}
// Add UI servlet at the end so its mappings don't obscure any from add-ons.
final ServletInfo uiServlet = Servlets.servlet("UI", UIServlet.class).setAsyncSupported(true).setLoadOnStartup(99).addMappings(UIServlet.PATHS);
uiServlet.setInstanceFactory(new ImmediateInstanceFactory<Servlet>(ui));
di.addServlet(uiServlet);
return di;
}
Aggregations