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.LoaderWebSocketServerFactory(javax.servlet.ServletContext context, WebSocketPolicy policy, ByteBufferPool bufferPool)protectedWebSocketServerFactory(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 booleanacceptWebSocket(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)java.lang.ObjectcreateWebSocket(ServletUpgradeRequest req, ServletUpgradeResponse resp)Default Creator logicprotected voiddoStart()Starts the managed lifecycle beans in the order they were added.protected voiddoStop()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.ByteBufferPoolgetBufferPool()The configured Container Buffer Pool.WebSocketCreatorgetCreator()EventDriverFactorygetEventDriverFactory()java.util.concurrent.ExecutorgetExecutor()Executor in use by the container.ExtensionFactorygetExtensionFactory()Deprecated.DecoratedObjectFactorygetObjectFactory()Object Factory used to create objects.java.util.Collection<WebSocketSession>getOpenSessions()WebSocketPolicygetPolicy()The policy the container is running on.java.util.Collection<WebSocketSessionListener>getSessionListeners()SslContextFactorygetSslContextFactory()The SslContextFactory in use by the container.booleanisUpgradeRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)voidregister(java.lang.Class<?> websocketPojo)Register a websocket class pojo with the defaultWebSocketCreator.voidremoveSessionListener(WebSocketSessionListener listener)voidsetCreator(WebSocketCreator creator)java.lang.StringtoString()-
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:
addSessionListenerin interfaceWebSocketContainerScope
-
removeSessionListener
public void removeSessionListener(WebSocketSessionListener listener)
- Specified by:
removeSessionListenerin interfaceWebSocketContainerScope
-
getSessionListeners
public java.util.Collection<WebSocketSessionListener> getSessionListeners()
- Specified by:
getSessionListenersin interfaceWebSocketContainerScope
-
acceptWebSocket
public boolean acceptWebSocket(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException- Specified by:
acceptWebSocketin 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:
acceptWebSocketin 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:
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
protected void doStart() throws java.lang.ExceptionDescription copied from class:ContainerLifeCycleStarts the managed lifecycle beans in the order they were added.- Overrides:
doStartin classContainerLifeCycle- Throws:
java.lang.Exception
-
doStop
protected void doStop() throws java.lang.ExceptionDescription copied from class:ContainerLifeCycleStops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStopin classContainerLifeCycle- Throws:
java.lang.Exception
-
getBufferPool
public ByteBufferPool getBufferPool()
Description copied from interface:WebSocketContainerScopeThe configured Container Buffer Pool.- Specified by:
getBufferPoolin interfaceWebSocketContainerScope- Returns:
- the buffer pool (never null)
-
getCreator
public WebSocketCreator getCreator()
- Specified by:
getCreatorin interfaceWebSocketServletFactory
-
getExecutor
public java.util.concurrent.Executor 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 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
public EventDriverFactory getEventDriverFactory()
-
getAvailableExtensionNames
public java.util.Set<java.lang.String> 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 public ExtensionFactory getExtensionFactory()
Deprecated.Description copied from interface:WebSocketServletFactoryGet the registered extensions for this WebSocket factory.- Specified by:
getExtensionFactoryin interfaceWebSocketServletFactory- Returns:
- the ExtensionFactory
- See Also:
WebSocketServletFactory.getAvailableExtensionNames()
-
getOpenSessions
public java.util.Collection<WebSocketSession> getOpenSessions()
-
getPolicy
public WebSocketPolicy 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 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
public void register(java.lang.Class<?> websocketPojo)
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
public void setCreator(WebSocketCreator creator)
- Specified by:
setCreatorin interfaceWebSocketServletFactory
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractLifeCycle
-
-