Class AnnotatedEndpoint

java.lang.Object
jakarta.websocket.Endpoint
org.glassfish.tyrus.core.AnnotatedEndpoint

public class AnnotatedEndpoint extends Endpoint
Endpoint descendant which represents deployed annotated endpoint.
Author:
Martin Matula, Stepan Kopriva, Pavel Bucek
  • Method Details

    • fromClass

      public static AnnotatedEndpoint fromClass(Class<?> annotatedClass, ComponentProviderService componentProvider, boolean isServerEndpoint, int incomingBufferSize, ErrorCollector collector, EndpointEventListener endpointEventListener)
      Create AnnotatedEndpoint from class.
      Parameters:
      annotatedClass - annotated class.
      componentProvider - used for instantiating.
      isServerEndpoint - true iff annotated endpoint is deployed on server side.
      incomingBufferSize - size limit of the incoming buffer.
      collector - error collector.
      endpointEventListener - listener of monitored endpoint events.
      Returns:
      new instance.
    • fromClass

      public static AnnotatedEndpoint fromClass(Class<?> annotatedClass, ComponentProviderService componentProvider, boolean isServerEndpoint, int incomingBufferSize, ErrorCollector collector, EndpointEventListener endpointEventListener, Set<Extension> extensions)
      Create AnnotatedEndpoint from class.
      Parameters:
      annotatedClass - annotated class.
      componentProvider - used for instantiating.
      isServerEndpoint - true iff annotated endpoint is deployed on server side.
      incomingBufferSize - size limit of the incoming buffer.
      collector - error collector.
      endpointEventListener - listener of monitored endpoint events.
      extensions - installed extentions.
      Returns:
      new instance.
    • fromInstance

      public static AnnotatedEndpoint fromInstance(Object annotatedInstance, ComponentProviderService componentProvider, boolean isServerEndpoint, int incomingBufferSize, ErrorCollector collector)
      Create AnnotatedEndpoint from instance.
      Parameters:
      annotatedInstance - annotated instance.
      componentProvider - used for instantiating.
      isServerEndpoint - true iff annotated endpoint is deployed on server side.
      incomingBufferSize - size limit of the incoming buffer
      collector - error collector.
      Returns:
      new instance.
    • fromInstance

      public static AnnotatedEndpoint fromInstance(Object annotatedInstance, ComponentProviderService componentProvider, boolean isServerEndpoint, int incomingBufferSize, ErrorCollector collector, Set<Extension> extensions)
      Create AnnotatedEndpoint from instance.
      Parameters:
      annotatedInstance - annotated instance.
      componentProvider - used for instantiating.
      isServerEndpoint - true iff annotated endpoint is deployed on server side.
      incomingBufferSize - size limit of the incoming buffer
      collector - error collector.
      extensions - installed extentions.
      Returns:
      new instance.
    • onClose

      public void onClose(Session session, CloseReason closeReason)
      Description copied from class: Endpoint
      This method is called immediately prior to the session with the remote peer being closed. It is called whether the session is being closed because the remote peer initiated a close and sent a close frame, or whether the local websocket container or this endpoint requests to close the session. The developer may take this last opportunity to retrieve session attributes such as the ID, or any application data it holds before it becomes unavailable after the completion of the method. Developers should not attempt to modify the session from within this method, or send new messages from this call as the underlying connection will not be able to send them at this stage.
      Overrides:
      onClose in class Endpoint
      Parameters:
      session - the session about to be closed.
      closeReason - the reason the session was closed.
    • onError

      public void onError(Session session, Throwable thr)
      Description copied from class: Endpoint
      Developers may implement this method when the web socket session creates some kind of error that is not modeled in the web socket protocol. This may for example be a notification that an incoming message is too big to handle, or that the incoming message could not be encoded.

      There are a number of categories of exception that this method is (currently) defined to handle:

      • connection problems, for example, a socket failure that occurs before the web socket connection can be formally closed. These are modeled as SessionExceptions
      • runtime errors thrown by developer created message handlers calls.
      • conversion errors encoding incoming messages before any message handler has been called. These are modeled as DecodeExceptions
      Overrides:
      onError in class Endpoint
      Parameters:
      session - the session in use when the error occurs.
      thr - the throwable representing the problem.
    • getEndpointConfig

      public EndpointConfig getEndpointConfig()
    • onOpen

      public void onOpen(Session session, EndpointConfig configuration)
      Description copied from class: Endpoint
      Developers must implement this method to be notified when a new conversation has just begun.

      Note:

      • It is permitted to send messages from this method.
      • It is permitted to add MessageHandlers from this method. No messages will be mapped to the appropriate MessageHandler until this method has completed.
      Specified by:
      onOpen in class Endpoint
      Parameters:
      session - the session that has just been activated.
      configuration - the configuration used to configure this endpoint.