Class JettyWebSocketInitializer

java.lang.Object
io.micronaut.servlet.websocket.jetty.JettyWebSocketInitializer
All Implemented Interfaces:
jakarta.servlet.ServletContainerInitializer

@Internal @Singleton @Requires(classes={org.eclipse.jetty.ee10.websocket.jakarta.server.config.JakartaWebSocketServletContainerInitializer.class,org.eclipse.jetty.ee10.servlet.ServletContextHandler.class}) @Requires(property="micronaut.servlet.websocket.enabled",notEquals="false",defaultValue="true") public final class JettyWebSocketInitializer extends Object implements jakarta.servlet.ServletContainerInitializer
Ensures that a Jakarta ServerContainer is available on the Jetty servlet context.

Jetty publishes the container through JakartaWebSocketServletContainerInitializer, which in embedded mode is never discovered by service loading because the Micronaut Jetty factory builds a plain ServletContextHandler. Registering this initializer as a bean is enough: the Jetty factory already adds every ServletContainerInitializer bean to the context.

Since:
6.2.0
Author:
graemerocher
  • Constructor Details

    • JettyWebSocketInitializer

      public JettyWebSocketInitializer(ServletWebSocketConfiguration configuration, io.micronaut.http.server.HttpServerConfiguration serverConfiguration, WebSocketContainerHolder holder)
      Default constructor.
      Parameters:
      configuration - The WebSocket configuration
      serverConfiguration - The server configuration, used for the default idle timeout
      holder - Where the container is registered for client connections
  • Method Details

    • onStartup

      public void onStartup(Set<Class<?>> classes, jakarta.servlet.ServletContext ctx) throws jakarta.servlet.ServletException
      Specified by:
      onStartup in interface jakarta.servlet.ServletContainerInitializer
      Throws:
      jakarta.servlet.ServletException