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.AbstractLifeCycleListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.ListenerNested classes/interfaces inherited from interface WebSocketServletFactory
WebSocketServletFactory.Loader -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.eclipse.jetty.io.ByteBufferPoolprivate final javax.servlet.ServletContextprivate final ClassLoaderprivate WebSocketCreatorprivate final WebSocketPolicyprivate final EventDriverFactoryprivate Executorprivate final WebSocketExtensionFactoryprivate final Map<Integer, WebSocketHandshake> private final List<WebSocketSessionListener> private static final org.eclipse.jetty.util.log.Loggerprivate org.eclipse.jetty.util.DecoratedObjectFactoryprivate final org.eclipse.jetty.util.thread.Schedulerprivate final List<SessionFactory> private final SessionTrackerprivate final Stringprivate static final Stringprivate static final StringFields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPINGFields 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.LoaderWebSocketServerFactory(javax.servlet.ServletContext context, WebSocketPolicy policy, org.eclipse.jetty.io.ByteBufferPool bufferPool) privateWebSocketServerFactory(javax.servlet.ServletContext context, WebSocketPolicy policy, org.eclipse.jetty.util.DecoratedObjectFactory objectFactory, Executor executor, org.eclipse.jetty.io.ByteBufferPool bufferPool) protectedWebSocketServerFactory(WebSocketPolicy policy, Executor executor, org.eclipse.jetty.io.ByteBufferPool bufferPool) Protected entry point forWebSocketHandler -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptWebSocket(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) booleanacceptWebSocket(WebSocketCreator creator, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) voidaddSessionFactory(SessionFactory sessionFactory) voidaddSessionListener(WebSocketSessionListener listener) private WebSocketSessioncreateSession(URI requestURI, EventDriver websocket, LogicalConnection connection) Default Creator logicprotected voiddoStart()protected voiddoStop()private org.eclipse.jetty.util.DecoratedObjectFactoryAttempt to find the DecoratedObjectFactory that should be used.private ExecutorAttempt to find the Executor that should be used.Get the set of available Extensions by registered name.org.eclipse.jetty.io.ByteBufferPoolThe configured Container Buffer Pool.Executor in use by the container.Deprecated.org.eclipse.jetty.util.DecoratedObjectFactoryObject Factory used to create objects.The policy the container is running on.private booleangetSendServerVersion(org.eclipse.jetty.server.Connector connector) org.eclipse.jetty.util.ssl.SslContextFactoryThe SslContextFactory in use by the container.booleanisUpgradeRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) voidRegister a websocket class pojo with the defaultWebSocketCreator.voidvoidsetCreator(WebSocketCreator creator) toString()private booleanupgrade(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, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stopMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Dumpable
dumpSelfMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpableMethods inherited from interface WebSocketContainerScope
getClassLoader, isRunningMethods inherited from interface 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:
addSessionListenerin interfaceWebSocketContainerScope
-
removeSessionListener
- Specified by:
removeSessionListenerin interfaceWebSocketContainerScope
-
getSessionListeners
- Specified by:
getSessionListenersin interfaceWebSocketContainerScope
-
acceptWebSocket
public boolean acceptWebSocket(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException - Specified by:
acceptWebSocketin interfaceWebSocketServletFactory- Throws:
IOException
-
acceptWebSocket
public boolean acceptWebSocket(WebSocketCreator creator, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException - Specified by:
acceptWebSocketin interfaceWebSocketServletFactory- Throws:
IOException
-
addSessionFactory
-
createSession
private WebSocketSession createSession(URI requestURI, EventDriver websocket, LogicalConnection connection) -
createWebSocket
Default Creator logic- Specified by:
createWebSocketin 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
-
doStop
-
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:WebSocketContainerScopeThe configured Container Buffer Pool.- Specified by:
getBufferPoolin interfaceWebSocketContainerScope- Returns:
- the buffer pool (never null)
-
getCreator
- Specified by:
getCreatorin interfaceWebSocketServletFactory
-
getExecutor
Description copied from interface:WebSocketContainerScopeExecutor in use by the container.- Specified by:
getExecutorin interfaceWebSocketContainerScope- Returns:
- the Executor in use by the container.
-
getObjectFactory
public org.eclipse.jetty.util.DecoratedObjectFactory getObjectFactory()Description copied from interface:WebSocketContainerScopeObject Factory used to create objects.- Specified by:
getObjectFactoryin interfaceWebSocketContainerScope- Returns:
- Object Factory used to create instances of objects.
-
getEventDriverFactory
-
getAvailableExtensionNames
Description copied from interface:WebSocketServletFactoryGet the set of available Extensions by registered name.- Specified by:
getAvailableExtensionNamesin interfaceWebSocketServletFactory- Returns:
- the set of available extensions by registered name.
-
getExtensionFactory
Deprecated.Description copied from interface:WebSocketServletFactoryGet the registered extensions for this WebSocket factory.- Specified by:
getExtensionFactoryin interfaceWebSocketServletFactory- Returns:
- the ExtensionFactory
- See Also:
-
getOpenSessions
-
getPolicy
Description copied from interface:WebSocketContainerScopeThe policy the container is running on.- Specified by:
getPolicyin interfaceWebSocketContainerScope- Specified by:
getPolicyin interfaceWebSocketServletFactory- Returns:
- the websocket policy
-
getSslContextFactory
public org.eclipse.jetty.util.ssl.SslContextFactory getSslContextFactory()Description copied from interface:WebSocketContainerScopeThe SslContextFactory in use by the container.- Specified by:
getSslContextFactoryin 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:
isUpgradeRequestin interfaceWebSocketServletFactory
-
register
Description copied from interface:WebSocketServletFactoryRegister a websocket class pojo with the defaultWebSocketCreator.Note: only required if using the default
WebSocketCreatorprovided by this factory.- Specified by:
registerin interfaceWebSocketServletFactory- Parameters:
websocketPojo- the class to instantiate for each incoming websocket upgrade request.
-
setCreator
- Specified by:
setCreatorin 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:
toStringin classorg.eclipse.jetty.util.component.AbstractLifeCycle
-