public class ServerEndpointRegistration extends javax.websocket.server.ServerEndpointConfig.Configurator implements javax.websocket.server.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
Constructor and Description |
---|
ServerEndpointRegistration(String path,
Class<? extends javax.websocket.Endpoint> endpointClass)
Create a new
ServerEndpointRegistration instance from an
javax.webscoket.Endpoint class. |
ServerEndpointRegistration(String path,
javax.websocket.Endpoint endpoint)
Create a new
ServerEndpointRegistration instance from an
javax.websocket.Endpoint instance. |
Modifier and Type | Method and Description |
---|---|
boolean |
checkOrigin(String originHeaderValue) |
javax.websocket.server.ServerEndpointConfig.Configurator |
getConfigurator() |
List<Class<? extends javax.websocket.Decoder>> |
getDecoders() |
List<Class<? extends javax.websocket.Encoder>> |
getEncoders() |
javax.websocket.Endpoint |
getEndpoint() |
Class<? extends javax.websocket.Endpoint> |
getEndpointClass() |
<T> T |
getEndpointInstance(Class<T> clazz) |
List<javax.websocket.Extension> |
getExtensions() |
List<javax.websocket.Extension> |
getNegotiatedExtensions(List<javax.websocket.Extension> installed,
List<javax.websocket.Extension> requested) |
String |
getNegotiatedSubprotocol(List<String> supported,
List<String> requested) |
String |
getPath() |
List<String> |
getSubprotocols() |
Map<String,Object> |
getUserProperties() |
void |
modifyHandshake(javax.websocket.server.ServerEndpointConfig sec,
javax.websocket.server.HandshakeRequest request,
javax.websocket.HandshakeResponse response) |
void |
setBeanFactory(BeanFactory beanFactory)
Callback that supplies the owning factory to a bean instance.
|
void |
setDecoders(List<Class<? extends javax.websocket.Decoder>> decoders) |
void |
setEncoders(List<Class<? extends javax.websocket.Encoder>> encoders) |
void |
setExtensions(List<javax.websocket.Extension> extensions) |
void |
setSubprotocols(List<String> protocols) |
void |
setUserProperties(Map<String,Object> userProperties) |
public ServerEndpointRegistration(String path, Class<? extends javax.websocket.Endpoint> endpointClass)
ServerEndpointRegistration
instance from an
javax.webscoket.Endpoint
class.path
- the endpoint pathendpointClass
- the endpoint classpublic ServerEndpointRegistration(String path, javax.websocket.Endpoint endpoint)
ServerEndpointRegistration
instance from an
javax.websocket.Endpoint
instance.path
- the endpoint pathendpoint
- the endpoint instancepublic String getPath()
getPath
in interface javax.websocket.server.ServerEndpointConfig
public Class<? extends javax.websocket.Endpoint> getEndpointClass()
getEndpointClass
in interface javax.websocket.server.ServerEndpointConfig
public javax.websocket.Endpoint getEndpoint()
public List<String> getSubprotocols()
getSubprotocols
in interface javax.websocket.server.ServerEndpointConfig
public void setExtensions(List<javax.websocket.Extension> extensions)
public List<javax.websocket.Extension> getExtensions()
getExtensions
in interface javax.websocket.server.ServerEndpointConfig
public Map<String,Object> getUserProperties()
getUserProperties
in interface javax.websocket.EndpointConfig
public List<Class<? extends javax.websocket.Encoder>> getEncoders()
getEncoders
in interface javax.websocket.EndpointConfig
public List<Class<? extends javax.websocket.Decoder>> getDecoders()
getDecoders
in interface javax.websocket.EndpointConfig
public javax.websocket.server.ServerEndpointConfig.Configurator getConfigurator()
getConfigurator
in interface javax.websocket.server.ServerEndpointConfig
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
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.BeansException
- in case of initialization errorsBeanInitializationException
public final <T> T getEndpointInstance(Class<T> clazz) throws InstantiationException
getEndpointInstance
in class javax.websocket.server.ServerEndpointConfig.Configurator
InstantiationException
public void modifyHandshake(javax.websocket.server.ServerEndpointConfig sec, javax.websocket.server.HandshakeRequest request, javax.websocket.HandshakeResponse response)
modifyHandshake
in class javax.websocket.server.ServerEndpointConfig.Configurator
public boolean checkOrigin(String originHeaderValue)
checkOrigin
in class javax.websocket.server.ServerEndpointConfig.Configurator
public String getNegotiatedSubprotocol(List<String> supported, List<String> requested)
getNegotiatedSubprotocol
in class javax.websocket.server.ServerEndpointConfig.Configurator