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:
Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
,WebSocketContainerScope
,WebSocketCreator
,WebSocketServletFactory
public class WebSocketServerFactory extends 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
AbstractLifeCycle.AbstractLifeCycleListener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Nested classes/interfaces inherited from interface org.eclipse.jetty.websocket.servlet.WebSocketServletFactory
WebSocketServletFactory.Loader
-
-
Constructor Summary
Constructors Modifier Constructor Description WebSocketServerFactory()
Entry point for Spring Boot's MockMVC frameworkWebSocketServerFactory(javax.servlet.ServletContext context)
WebSocketServerFactory(javax.servlet.ServletContext context, ByteBufferPool bufferPool)
WebSocketServerFactory(javax.servlet.ServletContext context, WebSocketPolicy policy)
Entry point forWebSocketServletFactory.Loader
WebSocketServerFactory(javax.servlet.ServletContext context, WebSocketPolicy policy, ByteBufferPool bufferPool)
protected
WebSocketServerFactory(WebSocketPolicy policy, java.util.concurrent.Executor executor, ByteBufferPool bufferPool)
Protected entry point forWebSocketHandler
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
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)
java.lang.Object
createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp)
Default Creator logicprotected void
doStart()
Starts the managed lifecycle beans in the order they were added.protected void
doStop()
Stops the managed lifecycle beans in the reverse order they were added.java.util.Set<java.lang.String>
getAvailableExtensionNames()
Get the set of available Extensions by registered name.ByteBufferPool
getBufferPool()
The configured Container Buffer Pool.WebSocketCreator
getCreator()
EventDriverFactory
getEventDriverFactory()
java.util.concurrent.Executor
getExecutor()
Executor in use by the container.ExtensionFactory
getExtensionFactory()
Deprecated.DecoratedObjectFactory
getObjectFactory()
Object Factory used to create objects.java.util.Collection<WebSocketSession>
getOpenSessions()
WebSocketPolicy
getPolicy()
The policy the container is running on.java.util.Collection<WebSocketSessionListener>
getSessionListeners()
SslContextFactory
getSslContextFactory()
The SslContextFactory in use by the container.boolean
isUpgradeRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
void
register(java.lang.Class<?> websocketPojo)
Register a websocket class pojo with the defaultWebSocketCreator
.void
removeSessionListener(WebSocketSessionListener listener)
void
setCreator(WebSocketCreator creator)
java.lang.String
toString()
-
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.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
-
-
-
-
Constructor Detail
-
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, ByteBufferPool bufferPool)
-
WebSocketServerFactory
public WebSocketServerFactory(javax.servlet.ServletContext context, WebSocketPolicy policy)
Entry point forWebSocketServletFactory.Loader
- Parameters:
context
- the servlet contextpolicy
- the policy to use
-
WebSocketServerFactory
public WebSocketServerFactory(javax.servlet.ServletContext context, WebSocketPolicy policy, ByteBufferPool bufferPool)
-
WebSocketServerFactory
protected WebSocketServerFactory(WebSocketPolicy policy, java.util.concurrent.Executor executor, ByteBufferPool bufferPool)
Protected entry point forWebSocketHandler
- Parameters:
policy
- the policy to useexecutor
- the executor to usebufferPool
- the buffer pool to use
-
-
Method Detail
-
addSessionListener
public void addSessionListener(WebSocketSessionListener listener)
- Specified by:
addSessionListener
in interfaceWebSocketContainerScope
-
removeSessionListener
public void removeSessionListener(WebSocketSessionListener listener)
- Specified by:
removeSessionListener
in interfaceWebSocketContainerScope
-
getSessionListeners
public java.util.Collection<WebSocketSessionListener> getSessionListeners()
- Specified by:
getSessionListeners
in interfaceWebSocketContainerScope
-
acceptWebSocket
public boolean acceptWebSocket(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
- Specified by:
acceptWebSocket
in interfaceWebSocketServletFactory
- Throws:
java.io.IOException
-
acceptWebSocket
public boolean acceptWebSocket(WebSocketCreator creator, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
- Specified by:
acceptWebSocket
in interfaceWebSocketServletFactory
- Throws:
java.io.IOException
-
addSessionFactory
public void addSessionFactory(SessionFactory sessionFactory)
-
createWebSocket
public java.lang.Object createWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp)
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
protected void doStart() throws java.lang.Exception
Description copied from class:ContainerLifeCycle
Starts the managed lifecycle beans in the order they were added.- Overrides:
doStart
in classContainerLifeCycle
- Throws:
java.lang.Exception
-
doStop
protected void doStop() throws java.lang.Exception
Description copied from class:ContainerLifeCycle
Stops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStop
in classContainerLifeCycle
- Throws:
java.lang.Exception
-
getBufferPool
public ByteBufferPool getBufferPool()
Description copied from interface:WebSocketContainerScope
The configured Container Buffer Pool.- Specified by:
getBufferPool
in interfaceWebSocketContainerScope
- Returns:
- the buffer pool (never null)
-
getCreator
public WebSocketCreator getCreator()
- Specified by:
getCreator
in interfaceWebSocketServletFactory
-
getExecutor
public java.util.concurrent.Executor 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 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
public EventDriverFactory getEventDriverFactory()
-
getAvailableExtensionNames
public java.util.Set<java.lang.String> 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 public ExtensionFactory 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:
WebSocketServletFactory.getAvailableExtensionNames()
-
getOpenSessions
public java.util.Collection<WebSocketSession> getOpenSessions()
-
getPolicy
public WebSocketPolicy 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 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
public void register(java.lang.Class<?> websocketPojo)
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
public void setCreator(WebSocketCreator creator)
- Specified by:
setCreator
in interfaceWebSocketServletFactory
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAbstractLifeCycle
-
-