public class ServerEndpointRegistration extends ServerEndpointConfig.Configurator implements ServerEndpointConfig, BeanFactoryAware
ServerEndpointConfig
for use in
Spring 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.
ServerEndpointExporter
ServerEndpointConfig.Builder, ServerEndpointConfig.Configurator
Constructor and Description |
---|
ServerEndpointRegistration(String path,
Class<? extends Endpoint> endpointClass)
Create a new
ServerEndpointRegistration instance from an
javax.websocket.Endpoint class. |
ServerEndpointRegistration(String path,
Endpoint endpoint)
Create a new
ServerEndpointRegistration instance from an
javax.websocket.Endpoint instance. |
public ServerEndpointRegistration(String path, Endpoint endpoint)
ServerEndpointRegistration
instance from an
javax.websocket.Endpoint
instance.path
- the endpoint pathendpoint
- the endpoint instancepublic ServerEndpointRegistration(String path, Class<? extends Endpoint> endpointClass)
ServerEndpointRegistration
instance from an
javax.websocket.Endpoint
class.path
- the endpoint pathendpointClass
- the endpoint classpublic String getPath()
getPath
in interface ServerEndpointConfig
public Class<? extends Endpoint> getEndpointClass()
getEndpointClass
in interface ServerEndpointConfig
public Endpoint getEndpoint()
public List<String> getSubprotocols()
getSubprotocols
in interface ServerEndpointConfig
public List<Extension> getExtensions()
getExtensions
in interface ServerEndpointConfig
public Map<String,Object> getUserProperties()
getUserProperties
in interface EndpointConfig
public List<Class<? extends Encoder>> getEncoders()
getEncoders
in interface EndpointConfig
public List<Class<? extends Decoder>> getDecoders()
getDecoders
in interface EndpointConfig
public ServerEndpointConfig.Configurator getConfigurator()
getConfigurator
in interface ServerEndpointConfig
public void setBeanFactory(BeanFactory beanFactory)
BeanFactoryAware
Invoked after the population of normal bean properties
but before an initialization callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method.
setBeanFactory
in interface BeanFactoryAware
beanFactory
- owning BeanFactory (never null
).
The bean can immediately call methods on the factory.BeanInitializationException
public final <T> T getEndpointInstance(Class<T> clazz) throws InstantiationException
getEndpointInstance
in class ServerEndpointConfig.Configurator
InstantiationException
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response)
modifyHandshake
in class ServerEndpointConfig.Configurator
public boolean checkOrigin(String originHeaderValue)
checkOrigin
in class ServerEndpointConfig.Configurator
public String getNegotiatedSubprotocol(List<String> supported, List<String> requested)
getNegotiatedSubprotocol
in class ServerEndpointConfig.Configurator
public List<Extension> getNegotiatedExtensions(List<Extension> installed, List<Extension> requested)
getNegotiatedExtensions
in class ServerEndpointConfig.Configurator