Class GuiceServerEndpointConfigurator

  • Direct Known Subclasses:
    PingingEndpointConfigurator

    public class GuiceServerEndpointConfigurator
    extends ServerEndpointConfig.Configurator
    Automatically injects dependencies of endpoint instances and ensures that lifecycle methods of the created endpoints are executed within WebsocketConnectionContext and ContainerCallContext.

    For endpoints annotated with @ServerEndpoint, this class must be used as configurator param of the annotation:

     @ServerEndpoint(
         value = "/websocket/mySocket",
         configurator = GuiceServerEndpointConfigurator.class)
     public class MyEndpoint {...}

    NOTE: methods annotated with @OnOpen must have a Session param.

    For endpoints added programmatically, a ServerEndpointConfig similar to the below should be used:

     websocketContainer.addEndpoint(ServerEndpointConfig.Builder
             .create(MyEndpoint.class, "/websocket/mySocket")
             .configurator(new GuiceServerEndpointConfigurator())
             .build());