public class WebSocketServerFactory extends ContainerLifeCycle implements WebSocketCreator
AbstractLifeCycle.AbstractLifeCycleListener
Container.InheritedListener, Container.Listener
LifeCycle.Listener
Constructor and Description |
---|
WebSocketServerFactory(WebSocketPolicy policy) |
WebSocketServerFactory(WebSocketPolicy policy,
ByteBufferPool bufferPool) |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptWebSocket(HttpServletRequest request,
HttpServletResponse response) |
protected void |
closeConnections() |
Object |
createWebSocket(UpgradeRequest req,
UpgradeResponse resp)
Default Creator logic
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
WebSocketCreator |
getCreator() |
ExtensionRegistry |
getExtensionRegistry() |
WebSocketPolicy |
getPolicy()
Get the base policy in use for WebSockets.
|
List<Extension> |
initExtensions(List<ExtensionConfig> requested) |
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) |
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, setStopTimeout, unmanage, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public WebSocketServerFactory(WebSocketPolicy policy)
public WebSocketServerFactory(WebSocketPolicy policy, ByteBufferPool bufferPool)
public boolean acceptWebSocket(HttpServletRequest request, HttpServletResponse response) throws IOException
IOException
protected void closeConnections()
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()
public ExtensionRegistry getExtensionRegistry()
public WebSocketPolicy getPolicy()
Note: individual WebSocket implementations can override some of the values in here by using the @WebSocket
annotation.
public List<Extension> initExtensions(List<ExtensionConfig> requested)
public boolean isUpgradeRequest(HttpServletRequest request, HttpServletResponse response)
public void register(Class<?> websocketPojo)
WebSocketCreator
.
Note: only required if using the default WebSocketCreator
provided by this factory.
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)
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
- in case of I/O errorsCopyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.