Annotation Interface OnClose


@Retention(RUNTIME) @Target(METHOD) public @interface OnClose
This method level annotation can be used to decorate a Java method that wishes to be called when a web socket session is closing.

The method may only take the following parameters:-

  • optional Session parameter
  • optional CloseReason parameter
  • Zero to n String parameters annotated with the jakarta.websocket.server.PathParam annotation.

The parameters may appear in any order. See Endpoint.onClose(jakarta.websocket.Session, jakarta.websocket.CloseReason) for more details on how the session parameter may be used during method calls annotated with this annotation.