public class ServerEndpointRegistration extends ServerEndpointConfig.Configurator implements ServerEndpointConfig, BeanFactoryAware
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.
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. |
Modifier and Type | Method and Description |
---|---|
ServerEndpointConfig.Configurator |
getConfigurator() |
List<Class<? extends Decoder>> |
getDecoders() |
List<Class<? extends Encoder>> |
getEncoders() |
Endpoint |
getEndpoint() |
Class<? extends Endpoint> |
getEndpointClass() |
<T> T |
getEndpointInstance(Class<T> clazz) |
List<Extension> |
getExtensions() |
String |
getPath() |
List<String> |
getSubprotocols() |
Map<String,Object> |
getUserProperties() |
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) |
String |
toString() |
checkOrigin, getNegotiatedExtensions, getNegotiatedSubprotocol
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 List<Class<? extends Encoder>> getEncoders()
getEncoders
in interface EndpointConfig
public List<Class<? extends Decoder>> getDecoders()
getDecoders
in interface EndpointConfig
public Map<String,Object> getUserProperties()
getUserProperties
in interface EndpointConfig
public ServerEndpointConfig.Configurator getConfigurator()
getConfigurator
in interface ServerEndpointConfig
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 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