Class DefaultSockJsService
- java.lang.Object
- org.springframework.web.socket.sockjs.support.AbstractSockJsService
- org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService
- org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService
- All Implemented Interfaces:
Aware
,Lifecycle
,ServletContextAware
,CorsConfigurationSource
,SockJsService
,SockJsServiceConfig
public class DefaultSockJsService extends TransportHandlingSockJsService implements ServletContextAware
A default implementation ofSockJsService
with all defaultTransportHandler
implementations pre-registered.- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller
Field Summary
Fields inherited from class org.springframework.web.socket.sockjs.support.AbstractSockJsService
allowedOrigins, logger
Constructor Summary
Constructors Constructor Description DefaultSockJsService(TaskScheduler scheduler)
Create a DefaultSockJsService with defaulthandler
types.DefaultSockJsService(TaskScheduler scheduler, Collection<TransportHandler> handlerOverrides)
Create a DefaultSockJsService with overriddenhandler
types replacing the corresponding default handler implementation.DefaultSockJsService(TaskScheduler scheduler, TransportHandler... handlerOverrides)
Create a DefaultSockJsService with overriddenhandler
types replacing the corresponding default handler implementation.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
setServletContext(ServletContext servletContext)
Set theServletContext
that this object runs in.Methods inherited from class org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService
getHandshakeInterceptors, getMessageCodec, getTransportHandlers, handleRawWebSocketRequest, handleTransportRequest, isRunning, setHandshakeInterceptors, setMessageCodec, start, stop, validateRequest
Methods inherited from class org.springframework.web.socket.sockjs.support.AbstractSockJsService
addCacheHeaders, addNoCacheHeaders, checkOrigin, getAllowedOrigins, getCorsConfiguration, getDisconnectDelay, getHeartbeatTime, getHttpMessageCacheSize, getName, getSockJsClientLibraryUrl, getStreamBytesLimit, getTaskScheduler, handleRequest, isSessionCookieNeeded, isWebSocketEnabled, sendMethodNotAllowed, setAllowedOrigins, setDisconnectDelay, setHeartbeatTime, setHttpMessageCacheSize, setName, setSessionCookieNeeded, setSockJsClientLibraryUrl, setStreamBytesLimit, setSuppressCors, setWebSocketEnabled, shouldSuppressCors
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.web.socket.sockjs.transport.SockJsServiceConfig
getHeartbeatTime, getHttpMessageCacheSize, getStreamBytesLimit, getTaskScheduler
Constructor Detail
DefaultSockJsService
public DefaultSockJsService(TaskScheduler scheduler)
Create a DefaultSockJsService with defaulthandler
types.- Parameters:
scheduler
- a task scheduler for heart-beat messages and removing timed-out sessions; the provided TaskScheduler should be declared as a Spring bean to ensure it is initialized at start up and shut down when the application stops.
DefaultSockJsService
public DefaultSockJsService(TaskScheduler scheduler, TransportHandler... handlerOverrides)
Create a DefaultSockJsService with overriddenhandler
types replacing the corresponding default handler implementation.- Parameters:
scheduler
- a task scheduler for heart-beat messages and removing timed-out sessions; the provided TaskScheduler should be declared as a Spring bean to ensure it gets initialized at start-up and shuts down when the application stopshandlerOverrides
- zero or more overrides to the default transport handler types
DefaultSockJsService
public DefaultSockJsService(TaskScheduler scheduler, Collection<TransportHandler> handlerOverrides)
Create a DefaultSockJsService with overriddenhandler
types replacing the corresponding default handler implementation.- Parameters:
scheduler
- a task scheduler for heart-beat messages and removing timed-out sessions; the provided TaskScheduler should be declared as a Spring bean to ensure it gets initialized at start-up and shuts down when the application stopshandlerOverrides
- zero or more overrides to the default transport handler types
Method Detail
setServletContext
public void setServletContext(ServletContext servletContext)
Description copied from interface:ServletContextAware
Set theServletContext
that this object runs in.Invoked after population of normal bean properties but before an init callback like InitializingBean's
afterPropertiesSet
or a custom init-method. Invoked after ApplicationContextAware'ssetApplicationContext
.- Specified by:
setServletContext
in interfaceServletContextAware
- Parameters:
servletContext
- the ServletContext object to be used by this object- See Also:
InitializingBean.afterPropertiesSet()
,ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)