use of io.undertow.websockets.jsr.WebSocketDeploymentInfo in project undertow by undertow-io.
the class JsrWebsocketExtensionTestCase method setup.
@BeforeClass
public static void setup() throws Exception {
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentInfo builder = new DeploymentInfo().setClassLoader(BinaryEndpointTest.class.getClassLoader()).setContextPath("/").setClassIntrospecter(TestClassIntrospector.INSTANCE).addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo().setDispatchToWorkerThread(true).setBuffers(DefaultServer.getBufferPool()).setWorker(DefaultServer.getWorkerSupplier()).addExtension(new PerMessageDeflateHandshake()).addEndpoint(AutobahnAnnotatedEndpoint.class)).setDeploymentName("servletContext.war");
deploymentManager = container.addDeployment(builder);
deploymentManager.deploy();
debug = new DebugExtensionsHeaderHandler(deploymentManager.start());
DefaultServer.setRootHandler(debug);
}
use of io.undertow.websockets.jsr.WebSocketDeploymentInfo in project spring-framework by spring-projects.
the class UndertowTestServer method deployConfig.
@Override
@SuppressWarnings("deprecation")
public void deployConfig(WebApplicationContext wac, Filter... filters) {
DispatcherServletInstanceFactory servletFactory = new DispatcherServletInstanceFactory(wac);
// manually building WebSocketDeploymentInfo in order to avoid class cast exceptions
// with tomcat's implementation when using undertow 1.1.0+
WebSocketDeploymentInfo info = new WebSocketDeploymentInfo();
try {
info.setWorker(Xnio.getInstance().createWorker(OptionMap.EMPTY));
info.setBuffers(new org.xnio.ByteBufferSlicePool(1024, 1024));
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
ServletInfo servletInfo = servlet("DispatcherServlet", DispatcherServlet.class, servletFactory).addMapping("/").setAsyncSupported(true);
DeploymentInfo servletBuilder = deployment().setClassLoader(UndertowTestServer.class.getClassLoader()).setDeploymentName("undertow-websocket-test").setContextPath("/").addServlet(servletInfo).addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, info);
for (final Filter filter : filters) {
String filterName = filter.getClass().getName();
FilterInstanceFactory filterFactory = new FilterInstanceFactory(filter);
FilterInfo filterInfo = new FilterInfo(filterName, filter.getClass(), filterFactory);
servletBuilder.addFilter(filterInfo.setAsyncSupported(true));
for (DispatcherType type : DispatcherType.values()) {
servletBuilder.addFilterUrlMapping(filterName, "/*", type);
}
}
try {
this.manager = defaultContainer().addDeployment(servletBuilder);
this.manager.deploy();
HttpHandler httpHandler = this.manager.start();
this.server = Undertow.builder().addHttpListener(0, "localhost").setHandler(httpHandler).build();
} catch (ServletException ex) {
throw new IllegalStateException(ex);
}
}
Aggregations