Search in sources :

Example 1 with JettyWebSocketServletContainerInitializer

use of org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer in project spring-framework by spring-projects.

the class JettyWebSocketTestServer method deployConfig.

@Override
public void deployConfig(WebApplicationContext wac, Filter... filters) {
    ServletHolder servletHolder = new ServletHolder(new DispatcherServlet(wac));
    this.contextHandler = new ServletContextHandler();
    this.contextHandler.addServlet(servletHolder, "/");
    this.contextHandler.addServletContainerInitializer(new JettyWebSocketServletContainerInitializer());
    for (Filter filter : filters) {
        this.contextHandler.addFilter(new FilterHolder(filter), "/*", getDispatcherTypes());
    }
    this.jettyServer.setHandler(this.contextHandler);
}
Also used : FilterHolder(org.eclipse.jetty.servlet.FilterHolder) JettyWebSocketServletContainerInitializer(org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer) Filter(jakarta.servlet.Filter) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) DispatcherServlet(org.springframework.web.servlet.DispatcherServlet) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 2 with JettyWebSocketServletContainerInitializer

use of org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer in project spring-framework by spring-projects.

the class JettyHttpServer method initServer.

@Override
protected void initServer() throws Exception {
    this.jettyServer = new Server();
    ServletHttpHandlerAdapter servlet = createServletAdapter();
    ServletHolder servletHolder = new ServletHolder(servlet);
    servletHolder.setAsyncSupported(true);
    this.contextHandler = new ServletContextHandler(this.jettyServer, "", false, false);
    this.contextHandler.addServlet(servletHolder, "/");
    this.contextHandler.addServletContainerInitializer(new JettyWebSocketServletContainerInitializer());
    this.contextHandler.start();
    ServerConnector connector = new ServerConnector(this.jettyServer);
    connector.setHost(getHost());
    connector.setPort(getPort());
    this.jettyServer.addConnector(connector);
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) Server(org.eclipse.jetty.server.Server) JettyWebSocketServletContainerInitializer(org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) ServletHttpHandlerAdapter(org.springframework.http.server.reactive.ServletHttpHandlerAdapter) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Aggregations

ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 JettyWebSocketServletContainerInitializer (org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer)2 Filter (jakarta.servlet.Filter)1 Server (org.eclipse.jetty.server.Server)1 ServerConnector (org.eclipse.jetty.server.ServerConnector)1 FilterHolder (org.eclipse.jetty.servlet.FilterHolder)1 ServletHttpHandlerAdapter (org.springframework.http.server.reactive.ServletHttpHandlerAdapter)1 DispatcherServlet (org.springframework.web.servlet.DispatcherServlet)1