Annotation Interface WebSocket


@Retention(RUNTIME) @Target(TYPE) public @interface WebSocket
Denotes a WebSocket server endpoint.

An endpoint must declare a method annotated with OnTextMessage, OnBinaryMessage, OnPingMessage, OnPongMessage or OnOpen. An endpoint may declare a method annotated with OnClose.

Lifecycle and concurrency

Endpoint implementation class must be a CDI bean. If no scope annotation is defined then Singleton is used. ApplicationScoped and Singleton endpoints are shared accross all WebSocket connections. Therefore, implementations should be either stateless or thread-safe.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The path of the endpoint.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    By default, the fully qualified name of the annotated class is used.
    The mode used to process incoming events for a specific connection.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Constant value for endpointId() indicating that the fully qualified name of the annotated class should be used.
  • Field Details

  • Element Details

    • path

      String path
      The path of the endpoint.

      It is possible to match path parameters. The placeholder of a path parameter consists of the parameter name surrounded by curly brackets. The actual value of a path parameter can be obtained using Connection.pathParam(String). For example, the path /foo/{bar} defines the path parameter bar.

      See Also:
    • endpointId

      String endpointId
      By default, the fully qualified name of the annotated class is used.
      Returns:
      the endpoint id
      See Also:
      Default:
      "<<fcqn name>>"
    • inboundProcessingMode

      InboundProcessingMode inboundProcessingMode
      The mode used to process incoming events for a specific connection.
      Default:
      SERIAL