Class WebSocketServerFactory
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.websocket.server.WebSocketServerFactory
- All Implemented Interfaces:
org.eclipse.jetty.util.component.Container
,org.eclipse.jetty.util.component.Destroyable
,org.eclipse.jetty.util.component.Dumpable
,org.eclipse.jetty.util.component.Dumpable.DumpableContainer
,org.eclipse.jetty.util.component.LifeCycle
,WebSocketContainerScope
,WebSocketCreator
,WebSocketServletFactory
public class WebSocketServerFactory
extends org.eclipse.jetty.util.component.ContainerLifeCycle
implements WebSocketCreator, WebSocketContainerScope, WebSocketServletFactory
Factory to create WebSocket connections
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.websocket.servlet.WebSocketServletFactory
WebSocketServletFactory.Loader
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.eclipse.jetty.io.ByteBufferPool
private final javax.servlet.ServletContext
private final ClassLoader
private WebSocketCreator
private final WebSocketPolicy
private final EventDriverFactory
private Executor
private final WebSocketExtensionFactory
private final Map<Integer,
WebSocketHandshake> private final List<WebSocketSessionListener>
private static final org.eclipse.jetty.util.log.Logger
private org.eclipse.jetty.util.DecoratedObjectFactory
private final org.eclipse.jetty.util.thread.Scheduler
private final List<SessionFactory>
private final SessionTracker
private final String
private static final String
private static final String
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
Fields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionEntry point for Spring Boot's MockMVC frameworkWebSocketServerFactory
(javax.servlet.ServletContext context) WebSocketServerFactory
(javax.servlet.ServletContext context, org.eclipse.jetty.io.ByteBufferPool bufferPool) WebSocketServerFactory
(javax.servlet.ServletContext context, WebSocketPolicy policy) Entry point forWebSocketServletFactory.Loader
WebSocketServerFactory
(javax.servlet.ServletContext context, WebSocketPolicy policy, org.eclipse.jetty.io.ByteBufferPool bufferPool) private
WebSocketServerFactory
(javax.servlet.ServletContext context, WebSocketPolicy policy, org.eclipse.jetty.util.DecoratedObjectFactory objectFactory, Executor executor, org.eclipse.jetty.io.ByteBufferPool bufferPool) protected
WebSocketServerFactory
(WebSocketPolicy policy, Executor executor, org.eclipse.jetty.io.ByteBufferPool bufferPool) Protected entry point forWebSocketHandler
-
Method Summary
Modifier and TypeMethodDescriptionboolean
acceptWebSocket
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) boolean
acceptWebSocket
(WebSocketCreator creator, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) void
addSessionFactory
(SessionFactory sessionFactory) void
addSessionListener
(WebSocketSessionListener listener) private WebSocketSession
createSession
(URI requestURI, EventDriver websocket, LogicalConnection connection) Default Creator logicprotected void
doStart()
protected void
doStop()
private org.eclipse.jetty.util.DecoratedObjectFactory
Attempt to find the DecoratedObjectFactory that should be used.private Executor
Attempt to find the Executor that should be used.Get the set of available Extensions by registered name.org.eclipse.jetty.io.ByteBufferPool
The configured Container Buffer Pool.Executor in use by the container.Deprecated.org.eclipse.jetty.util.DecoratedObjectFactory
Object Factory used to create objects.The policy the container is running on.private boolean
getSendServerVersion
(org.eclipse.jetty.server.Connector connector) org.eclipse.jetty.util.ssl.SslContextFactory
The SslContextFactory in use by the container.boolean
isUpgradeRequest
(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) void
Register a websocket class pojo with the defaultWebSocketCreator
.void
void
setCreator
(WebSocketCreator creator) toString()
private boolean
upgrade
(org.eclipse.jetty.server.HttpConnection http, ServletUpgradeRequest request, ServletUpgradeResponse response, EventDriver driver) Upgrade the request/response to a WebSocket Connection.Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable
dumpSelf
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope
getClassLoader, isRunning
Methods inherited from interface org.eclipse.jetty.websocket.servlet.WebSocketServletFactory
start, stop
-
Field Details
-
LOG
private static final org.eclipse.jetty.util.log.Logger LOG -
WEBSOCKET_INFLATER_POOL_ATTRIBUTE
- See Also:
-
WEBSOCKET_DEFLATER_POOL_ATTRIBUTE
- See Also:
-
contextClassloader
-
handshakes
-
scheduler
private final org.eclipse.jetty.util.thread.Scheduler scheduler -
listeners
-
supportedVersions
-
defaultPolicy
-
eventDriverFactory
-
bufferPool
private final org.eclipse.jetty.io.ByteBufferPool bufferPool -
extensionFactory
-
context
private final javax.servlet.ServletContext context -
sessionFactories
-
sessionTracker
-
registeredSocketClasses
-
executor
-
objectFactory
private org.eclipse.jetty.util.DecoratedObjectFactory objectFactory -
creator
-
-
Constructor Details
-
WebSocketServerFactory
public WebSocketServerFactory()Entry point for Spring Boot's MockMVC framework -
WebSocketServerFactory
public WebSocketServerFactory(javax.servlet.ServletContext context) -
WebSocketServerFactory
public WebSocketServerFactory(javax.servlet.ServletContext context, org.eclipse.jetty.io.ByteBufferPool bufferPool) -
WebSocketServerFactory
Entry point forWebSocketServletFactory.Loader
- Parameters:
context
- the servlet contextpolicy
- the policy to use
-
WebSocketServerFactory
public WebSocketServerFactory(javax.servlet.ServletContext context, WebSocketPolicy policy, org.eclipse.jetty.io.ByteBufferPool bufferPool) -
WebSocketServerFactory
protected WebSocketServerFactory(WebSocketPolicy policy, Executor executor, org.eclipse.jetty.io.ByteBufferPool bufferPool) Protected entry point forWebSocketHandler
- Parameters:
policy
- the policy to useexecutor
- the executor to usebufferPool
- the buffer pool to use
-
WebSocketServerFactory
private WebSocketServerFactory(javax.servlet.ServletContext context, WebSocketPolicy policy, org.eclipse.jetty.util.DecoratedObjectFactory objectFactory, Executor executor, org.eclipse.jetty.io.ByteBufferPool bufferPool)
-
-
Method Details
-
addSessionListener
- Specified by:
addSessionListener
in interfaceWebSocketContainerScope
-
removeSessionListener
- Specified by:
removeSessionListener
in interfaceWebSocketContainerScope
-
getSessionListeners
- Specified by:
getSessionListeners
in interfaceWebSocketContainerScope
-
acceptWebSocket
public boolean acceptWebSocket(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException - Specified by:
acceptWebSocket
in interfaceWebSocketServletFactory
- Throws:
IOException
-
acceptWebSocket
public boolean acceptWebSocket(WebSocketCreator creator, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException - Specified by:
acceptWebSocket
in interfaceWebSocketServletFactory
- Throws:
IOException
-
addSessionFactory
-
createSession
private WebSocketSession createSession(URI requestURI, EventDriver websocket, LogicalConnection connection) -
createWebSocket
Default Creator logic- Specified by:
createWebSocket
in interfaceWebSocketCreator
- Parameters:
req
- the request detailsresp
- the response details- Returns:
- a websocket object to use, or null if no websocket should be created from this request.
-
doStart
- Overrides:
doStart
in classorg.eclipse.jetty.util.component.ContainerLifeCycle
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.eclipse.jetty.util.component.ContainerLifeCycle
- Throws:
Exception
-
findDecoratedObjectFactory
private org.eclipse.jetty.util.DecoratedObjectFactory findDecoratedObjectFactory()Attempt to find the DecoratedObjectFactory that should be used.- Returns:
- the DecoratedObjectFactory that should be used. (never null)
-
findExecutor
Attempt to find the Executor that should be used.- Returns:
- the Executor that should be used. (never null)
-
getBufferPool
public org.eclipse.jetty.io.ByteBufferPool getBufferPool()Description copied from interface:WebSocketContainerScope
The configured Container Buffer Pool.- Specified by:
getBufferPool
in interfaceWebSocketContainerScope
- Returns:
- the buffer pool (never null)
-
getCreator
- Specified by:
getCreator
in interfaceWebSocketServletFactory
-
getExecutor
Description copied from interface:WebSocketContainerScope
Executor in use by the container.- Specified by:
getExecutor
in interfaceWebSocketContainerScope
- Returns:
- the Executor in use by the container.
-
getObjectFactory
public org.eclipse.jetty.util.DecoratedObjectFactory getObjectFactory()Description copied from interface:WebSocketContainerScope
Object Factory used to create objects.- Specified by:
getObjectFactory
in interfaceWebSocketContainerScope
- Returns:
- Object Factory used to create instances of objects.
-
getEventDriverFactory
-
getAvailableExtensionNames
Description copied from interface:WebSocketServletFactory
Get the set of available Extensions by registered name.- Specified by:
getAvailableExtensionNames
in interfaceWebSocketServletFactory
- Returns:
- the set of available extensions by registered name.
-
getExtensionFactory
Deprecated.Description copied from interface:WebSocketServletFactory
Get the registered extensions for this WebSocket factory.- Specified by:
getExtensionFactory
in interfaceWebSocketServletFactory
- Returns:
- the ExtensionFactory
- See Also:
-
getOpenSessions
-
getPolicy
Description copied from interface:WebSocketContainerScope
The policy the container is running on.- Specified by:
getPolicy
in interfaceWebSocketContainerScope
- Specified by:
getPolicy
in interfaceWebSocketServletFactory
- Returns:
- the websocket policy
-
getSslContextFactory
public org.eclipse.jetty.util.ssl.SslContextFactory getSslContextFactory()Description copied from interface:WebSocketContainerScope
The SslContextFactory in use by the container.- Specified by:
getSslContextFactory
in interfaceWebSocketContainerScope
- Returns:
- the SslContextFactory in use by the container (can be null if no SSL context is defined)
-
isUpgradeRequest
public boolean isUpgradeRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) - Specified by:
isUpgradeRequest
in interfaceWebSocketServletFactory
-
register
Description copied from interface:WebSocketServletFactory
Register a websocket class pojo with the defaultWebSocketCreator
.Note: only required if using the default
WebSocketCreator
provided by this factory.- Specified by:
register
in interfaceWebSocketServletFactory
- Parameters:
websocketPojo
- the class to instantiate for each incoming websocket upgrade request.
-
setCreator
- Specified by:
setCreator
in interfaceWebSocketServletFactory
-
upgrade
private boolean upgrade(org.eclipse.jetty.server.HttpConnection http, ServletUpgradeRequest request, ServletUpgradeResponse response, EventDriver driver) throws IOException Upgrade the request/response to a WebSocket Connection. This method will not normally return, but will instead throw a UpgradeConnectionException, to exit HTTP handling and initiate WebSocket handling of the connection.- Parameters:
http
- the raw http connectionrequest
- The request to upgraderesponse
- The response to upgradedriver
- The websocket handler implementation to use- Throws:
IOException
-
getSendServerVersion
private boolean getSendServerVersion(org.eclipse.jetty.server.Connector connector) -
toString
- Overrides:
toString
in classorg.eclipse.jetty.util.component.AbstractLifeCycle
-