Package org.glassfish.tyrus.core
Class AnnotatedEndpoint
java.lang.Object
jakarta.websocket.Endpoint
org.glassfish.tyrus.core.AnnotatedEndpoint
Endpoint
descendant which represents deployed annotated endpoint.- Author:
- Martin Matula, Stepan Kopriva, Pavel Bucek
-
Method Summary
Modifier and TypeMethodDescriptionstatic AnnotatedEndpoint
fromClass
(Class<?> annotatedClass, ComponentProviderService componentProvider, boolean isServerEndpoint, int incomingBufferSize, ErrorCollector collector, EndpointEventListener endpointEventListener) CreateAnnotatedEndpoint
from class.static AnnotatedEndpoint
fromClass
(Class<?> annotatedClass, ComponentProviderService componentProvider, boolean isServerEndpoint, int incomingBufferSize, ErrorCollector collector, EndpointEventListener endpointEventListener, Set<Extension> extensions) CreateAnnotatedEndpoint
from class.static AnnotatedEndpoint
fromInstance
(Object annotatedInstance, ComponentProviderService componentProvider, boolean isServerEndpoint, int incomingBufferSize, ErrorCollector collector) CreateAnnotatedEndpoint
from instance.static AnnotatedEndpoint
fromInstance
(Object annotatedInstance, ComponentProviderService componentProvider, boolean isServerEndpoint, int incomingBufferSize, ErrorCollector collector, Set<Extension> extensions) CreateAnnotatedEndpoint
from instance.void
onClose
(Session session, CloseReason closeReason) This method is called immediately prior to the session with the remote peer being closed.void
Developers may implement this method when the web socket session creates some kind of error that is not modeled in the web socket protocol.void
onOpen
(Session session, EndpointConfig configuration) Developers must implement this method to be notified when a new conversation has just begun.
-
Method Details
-
fromClass
public static AnnotatedEndpoint fromClass(Class<?> annotatedClass, ComponentProviderService componentProvider, boolean isServerEndpoint, int incomingBufferSize, ErrorCollector collector, EndpointEventListener endpointEventListener) CreateAnnotatedEndpoint
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) CreateAnnotatedEndpoint
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) CreateAnnotatedEndpoint
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 buffercollector
- error collector.- Returns:
- new instance.
-
fromInstance
public static AnnotatedEndpoint fromInstance(Object annotatedInstance, ComponentProviderService componentProvider, boolean isServerEndpoint, int incomingBufferSize, ErrorCollector collector, Set<Extension> extensions) CreateAnnotatedEndpoint
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 buffercollector
- error collector.extensions
- installed extentions.- Returns:
- new instance.
-
onClose
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. -
onError
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
SessionException
s - 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
DecodeException
s
- connection problems, for example, a socket failure that occurs before the web socket connection can be
formally closed. These are modeled as
-
getEndpointConfig
-
onOpen
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
MessageHandler
s from this method. No messages will be mapped to the appropriateMessageHandler
until this method has completed.
-