public class ServerEndpointExporter extends Object implements InitializingBean, BeanPostProcessor, ApplicationContextAware
ServerEndpointConfig and registers
with the standard Java WebSocket runtime. Also detects beans annotated with
ServerEndpoint and registers them as well. Although not required, it is likely
annotated endpoints should have their configurator property set to
SpringConfigurator.
When this class is used, by declaring it in Spring configuration, it should be
possible to turn off a Servlet container's scan for WebSocket endpoints. This can be
done with the help of the <absolute-ordering> element in web.xml.
ServerEndpointRegistration,
SpringConfigurator,
ServletServerContainerFactoryBean| Constructor and Description |
|---|
ServerEndpointExporter() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
protected javax.websocket.server.ServerContainer |
getServerContainer() |
Object |
postProcessAfterInitialization(Object bean,
String beanName)
Apply this BeanPostProcessor to the given new bean instance after any bean
initialization callbacks (like InitializingBean's
afterPropertiesSet
or a custom init-method). |
Object |
postProcessBeforeInitialization(Object bean,
String beanName)
Apply this BeanPostProcessor to the given new bean instance before any bean
initialization callbacks (like InitializingBean's
afterPropertiesSet
or a custom init-method). |
void |
setAnnotatedEndpointClasses(Class<?>... annotatedEndpointClasses)
Explicitly list annotated endpoint types that should be registered on startup.
|
void |
setApplicationContext(ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in.
|
public void setAnnotatedEndpointClasses(Class<?>... annotatedEndpointClasses)
annotatedEndpointClasses - ServerEndpoint-annotated typespublic void setApplicationContext(ApplicationContext applicationContext)
ApplicationContextAwareInvoked after population of normal bean properties but before an init callback such
as InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked after ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader),
ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) and
MessageSourceAware, if applicable.
setApplicationContext in interface ApplicationContextAwareapplicationContext - the ApplicationContext object to be used by this objectBeanInitializationExceptionprotected javax.websocket.server.ServerContainer getServerContainer()
public void afterPropertiesSet()
throws Exception
InitializingBeanThis method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet in interface InitializingBeanException - in the event of misconfiguration (such
as failure to set an essential property) or if initialization fails.public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
BeanPostProcessorafterPropertiesSet
or a custom init-method). The bean will already be populated with property values.
The returned bean instance may be a wrapper around the original.
In case of a FactoryBean, this callback will be invoked for both the FactoryBean
instance and the objects created by the FactoryBean (as of Spring 2.0). The
post-processor can decide whether to apply to either the FactoryBean or created
objects or both through corresponding bean instanceof FactoryBean checks.
This callback will also be invoked after a short-circuiting triggered by a
InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation(java.lang.Class<?>, java.lang.String) method,
in contrast to all other BeanPostProcessor callbacks.
postProcessAfterInitialization in interface BeanPostProcessorbean - the new bean instancebeanName - the name of the beannull, no subsequent BeanPostProcessors will be invokedBeansException - in case of errorsInitializingBean.afterPropertiesSet(),
FactoryBeanpublic Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
BeanPostProcessorafterPropertiesSet
or a custom init-method). The bean will already be populated with property values.
The returned bean instance may be a wrapper around the original.postProcessBeforeInitialization in interface BeanPostProcessorbean - the new bean instancebeanName - the name of the beannull, no subsequent BeanPostProcessors will be invokedBeansException - in case of errorsInitializingBean.afterPropertiesSet()