Class MicronautServerEndpoint

java.lang.Object
jakarta.websocket.Endpoint
io.micronaut.servlet.websocket.AbstractMicronautEndpoint
io.micronaut.servlet.websocket.MicronautServerEndpoint

@Internal public class MicronautServerEndpoint extends AbstractMicronautEndpoint
The Endpoint that adapts a connection the server accepted onto a Micronaut @ServerWebSocket bean, or onto a Jakarta @ServerEndpoint the annotation processor mapped onto one.

One instance exists per connection. All per-connection state arrives through the EndpointConfig user properties, so the class also works on containers that instantiate endpoints reflectively rather than through the configurator. The dispatch itself is AbstractMicronautEndpoint's; this class adds what only a server connection has: the upgrade request the handlers are bound against, the route's path variables, the session registry and the open and close events.

Since:
6.2.0
Author:
graemerocher
  • Field Details

  • Constructor Details

    • MicronautServerEndpoint

      public MicronautServerEndpoint()
      Public no-argument constructor, required by containers that create endpoint instances reflectively rather than through the configurator. The context is then read from the EndpointConfig user properties instead.
  • Method Details

    • onOpen

      public void onOpen(jakarta.websocket.Session session, jakarta.websocket.EndpointConfig config)
      Specified by:
      onOpen in class jakarta.websocket.Endpoint
    • propagatedContext

      protected io.micronaut.core.propagation.PropagatedContext propagatedContext()
      Handlers run with the upgrade request propagated, so that ServerRequestContext.currentRequest() resolves inside them.
      Specified by:
      propagatedContext in class AbstractMicronautEndpoint
      Returns:
      The propagated context
    • sessionOpened

      protected void sessionOpened(ServletWebSocketSession session)
      Description copied from class: AbstractMicronautEndpoint
      Called once the connection is set up, before the message handlers are registered and the open handler runs. Nothing by default.
      Overrides:
      sessionOpened in class AbstractMicronautEndpoint
      Parameters:
      session - The Micronaut session
    • sessionClosed

      protected void sessionClosed(ServletWebSocketSession session, boolean opened)
      Description copied from class: AbstractMicronautEndpoint
      Called once the session is closed and its close handler has run.
      Overrides:
      sessionClosed in class AbstractMicronautEndpoint
      Parameters:
      session - The Micronaut session
      opened - Whether the session had reached the open event
    • applyLimits

      protected void applyLimits(jakarta.websocket.Session session, @Nullable Integer declaredTextMax, @Nullable Integer declaredBinaryMax)
      Applies the payload limits. A Micronaut endpoint's one handler limits text and binary alike; a Jakarta endpoint declares maxMessageSize per handler. A limit no handler declares is the configured one.
      Overrides:
      applyLimits in class AbstractMicronautEndpoint
      Parameters:
      session - The container's session
      declaredTextMax - The text limit the text handler declares, or null
      declaredBinaryMax - The binary limit the binary handler declares, or null