public class ServerEndpointExporter extends WebApplicationObjectSupport implements BeanPostProcessor, InitializingBean
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
logger
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 ServerContainer |
getServerContainer()
Return the JSR-356
ServerContainer to use for endpoint registration. |
protected void |
initApplicationContext(ApplicationContext context)
Calls
WebApplicationObjectSupport.initServletContext(javax.servlet.ServletContext) if the
given ApplicationContext is a WebApplicationContext . |
protected void |
initServletContext(ServletContext servletContext)
Subclasses may override this for custom initialization based
on the ServletContext that this application object runs in.
|
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). |
protected void |
registerEndpoints()
Actually register the endpoints.
|
void |
setAnnotatedEndpointClasses(Class<?>... annotatedEndpointClasses)
Explicitly list annotated endpoint types that should be registered on startup.
|
void |
setServerContainer(ServerContainer serverContainer)
Set the JSR-356
ServerContainer to use for endpoint registration. |
getServletContext, getTempDir, getWebApplicationContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
public void setServerContainer(ServerContainer serverContainer)
ServerContainer
to use for endpoint registration.
If not set, the container is going to be retrieved via the ServletContext
.protected ServerContainer getServerContainer()
ServerContainer
to use for endpoint registration.public void setAnnotatedEndpointClasses(Class<?>... annotatedEndpointClasses)
annotatedEndpointClasses
- ServerEndpoint
-annotated typesprotected void initApplicationContext(ApplicationContext context)
WebApplicationObjectSupport
WebApplicationObjectSupport.initServletContext(javax.servlet.ServletContext)
if the
given ApplicationContext is a WebApplicationContext
.initApplicationContext
in class WebApplicationObjectSupport
context
- the containing ApplicationContextApplicationObjectSupport.setApplicationContext(org.springframework.context.ApplicationContext)
protected void initServletContext(ServletContext servletContext)
WebApplicationObjectSupport
The default implementation is empty. Called by
WebApplicationObjectSupport.initApplicationContext(org.springframework.context.ApplicationContext)
as well as WebApplicationObjectSupport.setServletContext(javax.servlet.ServletContext)
.
initServletContext
in class WebApplicationObjectSupport
servletContext
- the ServletContext that this application object runs in
(never null
)public void afterPropertiesSet()
InitializingBean
This 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 InitializingBean
protected void registerEndpoints()
afterPropertiesSet()
.public Object postProcessBeforeInitialization(Object bean, String beanName)
BeanPostProcessor
afterPropertiesSet
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 BeanPostProcessor
bean
- the new bean instancebeanName
- the name of the beannull
, no subsequent BeanPostProcessors will be invokedInitializingBean.afterPropertiesSet()
public Object postProcessAfterInitialization(Object bean, String beanName)
BeanPostProcessor
afterPropertiesSet
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 BeanPostProcessor
bean
- the new bean instancebeanName
- the name of the beannull
, no subsequent BeanPostProcessors will be invokedInitializingBean.afterPropertiesSet()
,
FactoryBean