类 JettyRequestUpgradeStrategy
- java.lang.Object
- org.springframework.web.socket.server.jetty.JettyRequestUpgradeStrategy
- 所有已实现的接口:
Aware
,Lifecycle
,ServletContextAware
,RequestUpgradeStrategy
public class JettyRequestUpgradeStrategy extends Object implements RequestUpgradeStrategy, ServletContextAware, Lifecycle
ARequestUpgradeStrategy
for use with Jetty 9.1-9.4. Based on Jetty's internalorg.eclipse.jetty.websocket.server.WebSocketHandler
class.- 从以下版本开始:
- 4.0
- 作者:
- Phillip Webb, Rossen Stoyanchev, Brian Clozel, Juergen Hoeller
构造器概要
构造器 构造器 说明 JettyRequestUpgradeStrategy()
Default constructor that createsWebSocketServerFactory
through its default constructor thus using a defaultWebSocketPolicy
.JettyRequestUpgradeStrategy(org.eclipse.jetty.websocket.api.WebSocketPolicy policy)
A constructor accepting aWebSocketPolicy
to be used when creating theWebSocketServerFactory
instance.JettyRequestUpgradeStrategy(org.eclipse.jetty.websocket.server.WebSocketServerFactory factory)
A constructor accepting aWebSocketServerFactory
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 List<WebSocketExtension>
getSupportedExtensions(ServerHttpRequest request)
Return the WebSocket protocol extensions supported by the underlying WebSocket server.String[]
getSupportedVersions()
Return the supported WebSocket protocol versions.boolean
isRunning()
Check whether this component is currently running.void
setServletContext(ServletContext servletContext)
Set theServletContext
that this object runs in.void
start()
Start this component.void
stop()
Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method.void
upgrade(ServerHttpRequest request, ServerHttpResponse response, String selectedProtocol, List<WebSocketExtension> selectedExtensions, Principal user, WebSocketHandler wsHandler, Map<String,Object> attributes)
Perform runtime specific steps to complete the upgrade.
构造器详细资料
JettyRequestUpgradeStrategy
public JettyRequestUpgradeStrategy()
Default constructor that createsWebSocketServerFactory
through its default constructor thus using a defaultWebSocketPolicy
.
JettyRequestUpgradeStrategy
public JettyRequestUpgradeStrategy(org.eclipse.jetty.websocket.api.WebSocketPolicy policy)
A constructor accepting aWebSocketPolicy
to be used when creating theWebSocketServerFactory
instance.- 参数:
policy
- the policy to use- 从以下版本开始:
- 4.3.5
JettyRequestUpgradeStrategy
public JettyRequestUpgradeStrategy(org.eclipse.jetty.websocket.server.WebSocketServerFactory factory)
A constructor accepting aWebSocketServerFactory
.- 参数:
factory
- the pre-configured factory to use
方法详细资料
setServletContext
public void setServletContext(ServletContext servletContext)
从接口复制的说明: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
.- 指定者:
setServletContext
在接口中ServletContextAware
- 参数:
servletContext
- ServletContext object to be used by this object- 另请参阅:
InitializingBean.afterPropertiesSet()
,ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
start
public void start()
从接口复制的说明:Lifecycle
Start this component.Should not throw an exception if the component is already running.
In the case of a container, this will propagate the start signal to all components that apply.
- 指定者:
start
在接口中Lifecycle
- 另请参阅:
SmartLifecycle.isAutoStartup()
stop
public void stop()
从接口复制的说明:Lifecycle
Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementingSmartLifecycle
and itsstop(Runnable)
variant when asynchronous stop behavior is necessary.Note that this stop notification is not guaranteed to come before destruction: On regular shutdown,
Lifecycle
beans will first receive a stop notification before the general destruction callbacks are being propagated; however, on hot refresh during a context's lifetime or on aborted refresh attempts, a given bean's destroy method will be called without any consideration of stop signals upfront.Should not throw an exception if the component is not running (not started yet).
In the case of a container, this will propagate the stop signal to all components that apply.
- 指定者:
stop
在接口中Lifecycle
- 另请参阅:
SmartLifecycle.stop(Runnable)
,DisposableBean.destroy()
isRunning
public boolean isRunning()
从接口复制的说明:Lifecycle
Check whether this component is currently running.In the case of a container, this will return
true
only if all components that apply are currently running.
getSupportedVersions
public String[] getSupportedVersions()
从接口复制的说明:RequestUpgradeStrategy
Return the supported WebSocket protocol versions.
getSupportedExtensions
public List<WebSocketExtension> getSupportedExtensions(ServerHttpRequest request)
从接口复制的说明:RequestUpgradeStrategy
Return the WebSocket protocol extensions supported by the underlying WebSocket server.
upgrade
public void upgrade(ServerHttpRequest request, ServerHttpResponse response, String selectedProtocol, List<WebSocketExtension> selectedExtensions, Principal user, WebSocketHandler wsHandler, Map<String,Object> attributes) throws HandshakeFailureException
从接口复制的说明:RequestUpgradeStrategy
Perform runtime specific steps to complete the upgrade. Invoked after successful negotiation of the handshake request.- 指定者:
upgrade
在接口中RequestUpgradeStrategy
- 参数:
request
- the current requestresponse
- the current responseselectedProtocol
- the selected sub-protocol, if anyselectedExtensions
- the selected WebSocket protocol extensionsuser
- the user to associate with the WebSocket sessionwsHandler
- the handler for WebSocket messagesattributes
- handshake request specific attributes to be set on the WebSocket session viaHandshakeInterceptor
and thus made available to theWebSocketHandler
- 抛出:
HandshakeFailureException
- thrown when handshake processing failed to complete due to an internal, unrecoverable error, i.e. a server error as opposed to a failure to successfully negotiate the requirements of the handshake request.