Class ServerEndpointRegistration
java.lang.Object
jakarta.websocket.server.ServerEndpointConfig.Configurator
org.springframework.web.socket.server.standard.ServerEndpointRegistration
- All Implemented Interfaces:
EndpointConfig
,ServerEndpointConfig
,Aware
,BeanFactoryAware
public class ServerEndpointRegistration
extends ServerEndpointConfig.Configurator
implements ServerEndpointConfig, BeanFactoryAware
An implementation of
ServerEndpointConfig
for use in
Spring-based applications. A ServerEndpointRegistration
bean is detected by
ServerEndpointExporter
and registered with a Java WebSocket runtime at startup.
Class constructors accept a singleton Endpoint
instance
or an Endpoint specified by type Class
. When specified by type, the endpoint
will be instantiated and initialized through the Spring ApplicationContext before
each client WebSocket connection.
This class also extends
ServerEndpointConfig.Configurator
to make it easier
to override methods for customizing the handshake process.
- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface jakarta.websocket.server.ServerEndpointConfig
ServerEndpointConfig.Builder, ServerEndpointConfig.Configurator
-
Constructor Summary
ConstructorDescriptionServerEndpointRegistration
(String path, Endpoint endpoint) Create a newServerEndpointRegistration
instance from anjakarta.websocket.Endpoint
instance.ServerEndpointRegistration
(String path, Class<? extends Endpoint> endpointClass) Create a newServerEndpointRegistration
instance from anjakarta.websocket.Endpoint
class. -
Method Summary
Modifier and TypeMethodDescriptionfinal <T> T
getEndpointInstance
(Class<T> clazz) getPath()
void
modifyHandshake
(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) void
setBeanFactory
(BeanFactory beanFactory) Callback that supplies the owning factory to a bean instance.void
setDecoders
(List<Class<? extends Decoder>> decoders) void
setEncoders
(List<Class<? extends Encoder>> encoders) void
setExtensions
(List<Extension> extensions) void
setSubprotocols
(List<String> subprotocols) void
setUserProperties
(Map<String, Object> userProperties) toString()
Methods inherited from class jakarta.websocket.server.ServerEndpointConfig.Configurator
checkOrigin, getContainerDefaultConfigurator, getNegotiatedExtensions, getNegotiatedSubprotocol
-
Constructor Details
-
ServerEndpointRegistration
Create a newServerEndpointRegistration
instance from anjakarta.websocket.Endpoint
instance.- Parameters:
path
- the endpoint pathendpoint
- the endpoint instance
-
ServerEndpointRegistration
Create a newServerEndpointRegistration
instance from anjakarta.websocket.Endpoint
class.- Parameters:
path
- the endpoint pathendpointClass
- the endpoint class
-
-
Method Details
-
getPath
- Specified by:
getPath
in interfaceServerEndpointConfig
-
getEndpointClass
- Specified by:
getEndpointClass
in interfaceServerEndpointConfig
-
getEndpoint
-
setSubprotocols
-
getSubprotocols
- Specified by:
getSubprotocols
in interfaceServerEndpointConfig
-
setExtensions
-
getExtensions
- Specified by:
getExtensions
in interfaceServerEndpointConfig
-
setEncoders
-
getEncoders
- Specified by:
getEncoders
in interfaceEndpointConfig
-
setDecoders
-
getDecoders
- Specified by:
getDecoders
in interfaceEndpointConfig
-
setUserProperties
-
getUserProperties
- Specified by:
getUserProperties
in interfaceEndpointConfig
-
getConfigurator
- Specified by:
getConfigurator
in interfaceServerEndpointConfig
-
getEndpointInstance
- Overrides:
getEndpointInstance
in classServerEndpointConfig.Configurator
- Throws:
InstantiationException
-
modifyHandshake
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) - Overrides:
modifyHandshake
in classServerEndpointConfig.Configurator
-
setBeanFactory
Description copied from interface:BeanFactoryAware
Callback that supplies the owning factory to a bean instance.Invoked after the population of normal bean properties but before an initialization callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method.- Specified by:
setBeanFactory
in interfaceBeanFactoryAware
- Parameters:
beanFactory
- owning BeanFactory (nevernull
). The bean can immediately call methods on the factory.- See Also:
-
toString
-