Class ServerEndpointRegistration
- java.lang.Object
- javax.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 ofServerEndpointConfigfor use in Spring-based applications. AServerEndpointRegistrationbean is detected byServerEndpointExporterand registered with a Java WebSocket runtime at startup.Class constructors accept a singleton
Endpointinstance or an Endpoint specified by typeClass. 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.Configuratorto make it easier to override methods for customizing the handshake process.- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller
- See Also:
ServerEndpointExporter
Nested Class Summary
Nested classes/interfaces inherited from interface javax.websocket.server.ServerEndpointConfig
ServerEndpointConfig.Builder, ServerEndpointConfig.Configurator
Constructor Summary
Constructors Constructor Description ServerEndpointRegistration(String path, Class<? extends Endpoint> endpointClass)Create a newServerEndpointRegistrationinstance from anjavax.websocket.Endpointclass.ServerEndpointRegistration(String path, Endpoint endpoint)Create a newServerEndpointRegistrationinstance from anjavax.websocket.Endpointinstance.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ServerEndpointConfig.ConfiguratorgetConfigurator()List<Class<? extends Decoder>>getDecoders()List<Class<? extends Encoder>>getEncoders()EndpointgetEndpoint()Class<? extends Endpoint>getEndpointClass()<T> TgetEndpointInstance(Class<T> clazz)List<Extension>getExtensions()StringgetPath()List<String>getSubprotocols()Map<String,Object>getUserProperties()voidmodifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response)voidsetBeanFactory(BeanFactory beanFactory)Callback that supplies the owning factory to a bean instance.voidsetDecoders(List<Class<? extends Decoder>> decoders)voidsetEncoders(List<Class<? extends Encoder>> encoders)voidsetExtensions(List<Extension> extensions)voidsetSubprotocols(List<String> subprotocols)voidsetUserProperties(Map<String,Object> userProperties)StringtoString()Methods inherited from class javax.websocket.server.ServerEndpointConfig.Configurator
checkOrigin, getNegotiatedExtensions, getNegotiatedSubprotocol
Constructor Detail
ServerEndpointRegistration
public ServerEndpointRegistration(String path, Endpoint endpoint)
Create a newServerEndpointRegistrationinstance from anjavax.websocket.Endpointinstance.- Parameters:
path- the endpoint pathendpoint- the endpoint instance
ServerEndpointRegistration
public ServerEndpointRegistration(String path, Class<? extends Endpoint> endpointClass)
Create a newServerEndpointRegistrationinstance from anjavax.websocket.Endpointclass.- Parameters:
path- the endpoint pathendpointClass- the endpoint class
Method Detail
getPath
public String getPath()
- Specified by:
getPathin interfaceServerEndpointConfig
getEndpointClass
public Class<? extends Endpoint> getEndpointClass()
- Specified by:
getEndpointClassin interfaceServerEndpointConfig
getEndpoint
public Endpoint getEndpoint()
setSubprotocols
public void setSubprotocols(List<String> subprotocols)
getSubprotocols
public List<String> getSubprotocols()
- Specified by:
getSubprotocolsin interfaceServerEndpointConfig
setExtensions
public void setExtensions(List<Extension> extensions)
getExtensions
public List<Extension> getExtensions()
- Specified by:
getExtensionsin interfaceServerEndpointConfig
setEncoders
public void setEncoders(List<Class<? extends Encoder>> encoders)
getEncoders
public List<Class<? extends Encoder>> getEncoders()
- Specified by:
getEncodersin interfaceEndpointConfig
setDecoders
public void setDecoders(List<Class<? extends Decoder>> decoders)
getDecoders
public List<Class<? extends Decoder>> getDecoders()
- Specified by:
getDecodersin interfaceEndpointConfig
setUserProperties
public void setUserProperties(Map<String,Object> userProperties)
getUserProperties
public Map<String,Object> getUserProperties()
- Specified by:
getUserPropertiesin interfaceEndpointConfig
getConfigurator
public ServerEndpointConfig.Configurator getConfigurator()
- Specified by:
getConfiguratorin interfaceServerEndpointConfig
getEndpointInstance
public final <T> T getEndpointInstance(Class<T> clazz) throws InstantiationException
- Overrides:
getEndpointInstancein classServerEndpointConfig.Configurator- Throws:
InstantiationException
modifyHandshake
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response)
- Overrides:
modifyHandshakein classServerEndpointConfig.Configurator
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)
Description copied from interface:BeanFactoryAwareCallback 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:
setBeanFactoryin interfaceBeanFactoryAware- Parameters:
beanFactory- owning BeanFactory (nevernull). The bean can immediately call methods on the factory.- See Also:
BeanInitializationException