public class WebSocketServerFactory extends ContainerLifeCycle implements WebSocketCreator, WebSocketServletFactory
AbstractLifeCycle.AbstractLifeCycleListener
Container.InheritedListener, Container.Listener
LifeCycle.Listener
Constructor and Description |
---|
WebSocketServerFactory() |
WebSocketServerFactory(WebSocketPolicy policy) |
WebSocketServerFactory(WebSocketPolicy policy,
ByteBufferPool bufferPool) |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptWebSocket(HttpServletRequest request,
HttpServletResponse response) |
void |
cleanup() |
protected void |
closeAllConnections() |
WebSocketServletFactory |
createFactory(WebSocketPolicy policy) |
Object |
createWebSocket(UpgradeRequest req,
UpgradeResponse resp)
Default Creator logic
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
static UpgradeContext |
getActiveUpgradeContext() |
WebSocketCreator |
getCreator() |
ExtensionFactory |
getExtensionFactory() |
WebSocketPolicy |
getPolicy()
Get the base policy in use for WebSockets.
|
void |
init() |
boolean |
isUpgradeRequest(HttpServletRequest request,
HttpServletResponse response) |
protected String[] |
parseProtocols(String protocol) |
void |
register(Class<?> websocketPojo)
Register a websocket class pojo with the default
WebSocketCreator . |
boolean |
sessionClosed(WebSocketSession session) |
boolean |
sessionOpened(WebSocketSession session) |
protected static void |
setActiveUpgradeContext(UpgradeContext connection) |
void |
setCreator(WebSocketCreator creator) |
boolean |
upgrade(ServletWebSocketRequest request,
ServletWebSocketResponse response,
EventDriver driver)
Upgrade the request/response to a WebSocket Connection.
|
addBean, addBean, addBean, contains, destroy, doStart, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, setBeans, setStopTimeout, start, unmanage, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public WebSocketServerFactory()
public WebSocketServerFactory(WebSocketPolicy policy)
public WebSocketServerFactory(WebSocketPolicy policy, ByteBufferPool bufferPool)
public static UpgradeContext getActiveUpgradeContext()
protected static void setActiveUpgradeContext(UpgradeContext connection)
public boolean acceptWebSocket(HttpServletRequest request, HttpServletResponse response) throws IOException
acceptWebSocket
in interface WebSocketServletFactory
IOException
public void cleanup()
cleanup
in interface WebSocketServletFactory
protected void closeAllConnections()
public WebSocketServletFactory createFactory(WebSocketPolicy policy)
createFactory
in interface WebSocketServletFactory
public Object createWebSocket(UpgradeRequest req, UpgradeResponse resp)
createWebSocket
in interface WebSocketCreator
req
- the request detailsprotected void doStop() throws Exception
ContainerLifeCycle
doStop
in class ContainerLifeCycle
Exception
public WebSocketCreator getCreator()
getCreator
in interface WebSocketServletFactory
public ExtensionFactory getExtensionFactory()
getExtensionFactory
in interface WebSocketServletFactory
public WebSocketPolicy getPolicy()
WebSocketServletFactory
Note: individual WebSocket implementations can override some of the values in here by using the @WebSocket
annotation.
getPolicy
in interface WebSocketServletFactory
public void init() throws Exception
init
in interface WebSocketServletFactory
Exception
public boolean isUpgradeRequest(HttpServletRequest request, HttpServletResponse response)
isUpgradeRequest
in interface WebSocketServletFactory
public void register(Class<?> websocketPojo)
WebSocketServletFactory
WebSocketCreator
.
Note: only required if using the default WebSocketCreator
provided by this factory.
register
in interface WebSocketServletFactory
websocketPojo
- the class to instantiate for each incoming websocket upgrade request.public boolean sessionClosed(WebSocketSession session)
public boolean sessionOpened(WebSocketSession session)
public void setCreator(WebSocketCreator creator)
setCreator
in interface WebSocketServletFactory
public boolean upgrade(ServletWebSocketRequest request, ServletWebSocketResponse response, EventDriver driver) throws IOException
This method will not normally return, but will instead throw a UpgradeConnectionException, to exit HTTP handling and initiate WebSocket handling of the connection.
request
- The request to upgraderesponse
- The response to upgradedriver
- The websocket handler implementation to useIOException
Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.