Class ClientContainer
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.eclipse.jetty.websocket.jsr356.ClientContainer
-
- All Implemented Interfaces:
javax.websocket.WebSocketContainer
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
,WebSocketContainerScope
- Direct Known Subclasses:
ServerContainer
@ManagedObject("JSR356 Client Container") public class ClientContainer extends ContainerLifeCycle implements javax.websocket.WebSocketContainer, WebSocketContainerScope
Container for Client use of the javax.websocket API.This should be specific to a JVM if run in a standalone mode. or specific to a WebAppContext if running on the Jetty server.
-
-
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
-
-
Constructor Summary
Constructors Modifier Constructor Description ClientContainer()
This is the entry point forContainerProvider.getWebSocketContainer()
ClientContainer(HttpClient httpClient)
Create aWebSocketContainer
using the suppliedHttpClient
for environments where you want to configure SSL/TLS or Proxy behaviors.ClientContainer(WebSocketClient client)
Build a ClientContainer with a specific WebSocketClient in mind.ClientContainer(WebSocketContainerScope scope)
This is the entry point for ServerContainer, via ServletContext.getAttribute(ServerContainer.class.getName())protected
ClientContainer(WebSocketContainerScope scope, HttpClient httpClient)
This is the entry point for ServerContainer, via ServletContext.getAttribute(ServerContainer.class.getName())
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSessionListener(WebSocketSessionListener listener)
javax.websocket.Session
connectToServer(java.lang.Class<?> annotatedEndpointClass, java.net.URI path)
javax.websocket.Session
connectToServer(java.lang.Class<? extends javax.websocket.Endpoint> endpointClass, javax.websocket.ClientEndpointConfig config, java.net.URI path)
javax.websocket.Session
connectToServer(java.lang.Object endpoint, java.net.URI path)
javax.websocket.Session
connectToServer(javax.websocket.Endpoint endpoint, javax.websocket.ClientEndpointConfig config, java.net.URI path)
protected 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.ByteBufferPool
getBufferPool()
The configured Container Buffer Pool.java.lang.ClassLoader
getClassLoader()
The ClassLoader used to load classes for the WebSocketSession.WebSocketClient
getClient()
EndpointMetadata
getClientEndpointMetadata(java.lang.Class<?> endpoint, javax.websocket.EndpointConfig config)
DecoderFactory
getDecoderFactory()
long
getDefaultAsyncSendTimeout()
int
getDefaultMaxBinaryMessageBufferSize()
long
getDefaultMaxSessionIdleTimeout()
int
getDefaultMaxTextMessageBufferSize()
EncoderFactory
getEncoderFactory()
java.util.concurrent.Executor
getExecutor()
Executor in use by the container.java.util.Set<javax.websocket.Extension>
getInstalledExtensions()
DecoratedObjectFactory
getObjectFactory()
Object Factory used to create objects.java.util.Set<javax.websocket.Session>
getOpenSessions()
Used inSession.getOpenSessions()
WebSocketPolicy
getPolicy()
The policy the container is running on.java.util.Collection<WebSocketSessionListener>
getSessionListeners()
SslContextFactory
getSslContextFactory()
The SslContextFactory in use by the container.EndpointInstance
newClientEndpointInstance(java.lang.Object endpoint, javax.websocket.ClientEndpointConfig config)
void
removeSessionListener(WebSocketSessionListener listener)
void
setAsyncSendTimeout(long ms)
void
setDefaultMaxBinaryMessageBufferSize(int max)
void
setDefaultMaxSessionIdleTimeout(long ms)
void
setDefaultMaxTextMessageBufferSize(int max)
-
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, toString
-
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
isRunning
-
-
-
-
Constructor Detail
-
ClientContainer
public ClientContainer()
This is the entry point forContainerProvider.getWebSocketContainer()
-
ClientContainer
public ClientContainer(HttpClient httpClient)
Create aWebSocketContainer
using the suppliedHttpClient
for environments where you want to configure SSL/TLS or Proxy behaviors.- Parameters:
httpClient
- the HttpClient instance to use
-
ClientContainer
public ClientContainer(WebSocketContainerScope scope)
This is the entry point for ServerContainer, via ServletContext.getAttribute(ServerContainer.class.getName())- Parameters:
scope
- the scope of the ServerContainer
-
ClientContainer
protected ClientContainer(WebSocketContainerScope scope, HttpClient httpClient)
This is the entry point for ServerContainer, via ServletContext.getAttribute(ServerContainer.class.getName())- Parameters:
scope
- the scope of the ServerContainerhttpClient
- the HttpClient instance to use
-
ClientContainer
public ClientContainer(WebSocketClient client)
Build a ClientContainer with a specific WebSocketClient in mind.- Parameters:
client
- the WebSocketClient to use.
-
-
Method Detail
-
connectToServer
public javax.websocket.Session connectToServer(java.lang.Class<? extends javax.websocket.Endpoint> endpointClass, javax.websocket.ClientEndpointConfig config, java.net.URI path) throws javax.websocket.DeploymentException, java.io.IOException
- Specified by:
connectToServer
in interfacejavax.websocket.WebSocketContainer
- Throws:
javax.websocket.DeploymentException
java.io.IOException
-
connectToServer
public javax.websocket.Session connectToServer(java.lang.Class<?> annotatedEndpointClass, java.net.URI path) throws javax.websocket.DeploymentException, java.io.IOException
- Specified by:
connectToServer
in interfacejavax.websocket.WebSocketContainer
- Throws:
javax.websocket.DeploymentException
java.io.IOException
-
connectToServer
public javax.websocket.Session connectToServer(javax.websocket.Endpoint endpoint, javax.websocket.ClientEndpointConfig config, java.net.URI path) throws javax.websocket.DeploymentException, java.io.IOException
- Specified by:
connectToServer
in interfacejavax.websocket.WebSocketContainer
- Throws:
javax.websocket.DeploymentException
java.io.IOException
-
connectToServer
public javax.websocket.Session connectToServer(java.lang.Object endpoint, java.net.URI path) throws javax.websocket.DeploymentException, java.io.IOException
- Specified by:
connectToServer
in interfacejavax.websocket.WebSocketContainer
- Throws:
javax.websocket.DeploymentException
java.io.IOException
-
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)
-
getClient
public WebSocketClient getClient()
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
Description copied from interface:WebSocketContainerScope
The ClassLoader used to load classes for the WebSocketSession.
By default this will be the ContextClassLoader at the time this method is called. However this will be overridden by the WebSocketClient to use the ContextClassLoader at the time it was created, this is because the client uses its own
ThreadPool
so the WebSocketSessions may be created when the ContextClassLoader is not set.- Specified by:
getClassLoader
in interfaceWebSocketContainerScope
- Returns:
- the classloader.
-
getClientEndpointMetadata
public EndpointMetadata getClientEndpointMetadata(java.lang.Class<?> endpoint, javax.websocket.EndpointConfig config)
-
getDecoderFactory
public DecoderFactory getDecoderFactory()
-
getDefaultAsyncSendTimeout
public long getDefaultAsyncSendTimeout()
- Specified by:
getDefaultAsyncSendTimeout
in interfacejavax.websocket.WebSocketContainer
-
getDefaultMaxBinaryMessageBufferSize
public int getDefaultMaxBinaryMessageBufferSize()
- Specified by:
getDefaultMaxBinaryMessageBufferSize
in interfacejavax.websocket.WebSocketContainer
-
getDefaultMaxSessionIdleTimeout
public long getDefaultMaxSessionIdleTimeout()
- Specified by:
getDefaultMaxSessionIdleTimeout
in interfacejavax.websocket.WebSocketContainer
-
getDefaultMaxTextMessageBufferSize
public int getDefaultMaxTextMessageBufferSize()
- Specified by:
getDefaultMaxTextMessageBufferSize
in interfacejavax.websocket.WebSocketContainer
-
getEncoderFactory
public EncoderFactory getEncoderFactory()
-
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.
-
getInstalledExtensions
public java.util.Set<javax.websocket.Extension> getInstalledExtensions()
- Specified by:
getInstalledExtensions
in interfacejavax.websocket.WebSocketContainer
-
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.
-
getOpenSessions
public java.util.Set<javax.websocket.Session> getOpenSessions()
Used inSession.getOpenSessions()
- Returns:
- the set of open sessions
-
getPolicy
public WebSocketPolicy getPolicy()
Description copied from interface:WebSocketContainerScope
The policy the container is running on.- Specified by:
getPolicy
in interfaceWebSocketContainerScope
- 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)
-
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
-
newClientEndpointInstance
public EndpointInstance newClientEndpointInstance(java.lang.Object endpoint, javax.websocket.ClientEndpointConfig config)
-
setAsyncSendTimeout
public void setAsyncSendTimeout(long ms)
- Specified by:
setAsyncSendTimeout
in interfacejavax.websocket.WebSocketContainer
-
setDefaultMaxBinaryMessageBufferSize
public void setDefaultMaxBinaryMessageBufferSize(int max)
- Specified by:
setDefaultMaxBinaryMessageBufferSize
in interfacejavax.websocket.WebSocketContainer
-
setDefaultMaxSessionIdleTimeout
public void setDefaultMaxSessionIdleTimeout(long ms)
- Specified by:
setDefaultMaxSessionIdleTimeout
in interfacejavax.websocket.WebSocketContainer
-
setDefaultMaxTextMessageBufferSize
public void setDefaultMaxTextMessageBufferSize(int max)
- Specified by:
setDefaultMaxTextMessageBufferSize
in interfacejavax.websocket.WebSocketContainer
-
-