Annotation Interface OnOpen


@Retention(RUNTIME) @Target(METHOD) public @interface OnOpen
WebSocket and WebSocketClient endpoint methods annotated with this annotation are invoked when a new connection is opened. An endpoint may declare at most one method annotated with this annotation.

Execution model

  • Methods annotated with RunOnVirtualThread are considered blocking and should be executed on a virtual thread.
  • Methods annotated with Blocking are considered blocking and should be executed on a worker thread.
  • Methods annotated with NonBlocking are considered non-blocking and should be executed on an event loop thread.
Execution model for methods which don't declare any of the annotation listed above is derived from the return type:

  • Methods returning void are considered blocking and should be executed on a worker thread.
  • Methods returning Uni or Multi are considered non-blocking and should be executed on an event loop thread.
  • Methods returning any other type are considered blocking and should be executed on a worker thread.

Method parameters

The method may accept the following parameters:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Broadcasting is only supported for server endpoints annotated with WebSocket.
  • Element Details

    • broadcast

      boolean broadcast
      Broadcasting is only supported for server endpoints annotated with WebSocket.
      Returns:
      true if all the connected clients should receive the objects emitted by the annotated method
      See Also:
      Default:
      false