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
,org.eclipse.jetty.util.component.Container
,org.eclipse.jetty.util.component.Destroyable
,org.eclipse.jetty.util.component.Dumpable
,org.eclipse.jetty.util.component.Dumpable.DumpableContainer
,org.eclipse.jetty.util.component.LifeCycle
,WebSocketContainerScope
- Direct Known Subclasses:
ServerContainer
@ManagedObject("JSR356 Client Container")
public class ClientContainer
extends org.eclipse.jetty.util.component.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 ClassesNested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.Listener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final WebSocketClient
The jetty websocket client in use for this containerprivate final DecoderFactory
Tracking all primitive decoders for the containerprivate final EncoderFactory
Tracking all primitive encoders for the containerprivate final Map
<Class<?>, EndpointMetadata> Tracking for all declared Client endpointsprivate final boolean
private static final org.eclipse.jetty.util.log.Logger
private final WebSocketContainerScope
The delegated Container Scopeprivate final JsrSessionTracker
Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
Fields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionThis is the entry point forContainerProvider.getWebSocketContainer()
ClientContainer
(org.eclipse.jetty.client.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.This is the entry point for ServerContainer, via ServletContext.getAttribute(ServerContainer.class.getName())protected
ClientContainer
(WebSocketContainerScope scope, org.eclipse.jetty.client.HttpClient httpClient) This is the entry point for ServerContainer, via ServletContext.getAttribute(ServerContainer.class.getName()) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSessionListener
(WebSocketSessionListener listener) private javax.websocket.Session
connect
(EndpointInstance instance, URI path) javax.websocket.Session
connectToServer
(Class<?> annotatedEndpointClass, URI path) javax.websocket.Session
connectToServer
(Class<? extends javax.websocket.Endpoint> endpointClass, javax.websocket.ClientEndpointConfig config, URI path) javax.websocket.Session
connectToServer
(Object endpoint, URI path) javax.websocket.Session
connectToServer
(javax.websocket.Endpoint endpoint, javax.websocket.ClientEndpointConfig config, URI path) protected void
doStart()
protected void
doStop()
org.eclipse.jetty.io.ByteBufferPool
The configured Container Buffer Pool.The ClassLoader used to load classes for the WebSocketSession.getClientEndpointMetadata
(Class<?> endpoint, javax.websocket.EndpointConfig config) long
int
long
int
Executor in use by the container.Set
<javax.websocket.Extension> org.eclipse.jetty.util.DecoratedObjectFactory
Object Factory used to create objects.Set
<javax.websocket.Session> Used inSession.getOpenSessions()
The policy the container is running on.org.eclipse.jetty.util.ssl.SslContextFactory
The SslContextFactory in use by the container.private EndpointInstance
newClientEndpointInstance
(Class<?> endpointClass, javax.websocket.ClientEndpointConfig config) newClientEndpointInstance
(Object endpoint, javax.websocket.ClientEndpointConfig config) void
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
dumpSelf
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.websocket.common.scopes.WebSocketContainerScope
isRunning
-
Field Details
-
LOG
private static final org.eclipse.jetty.util.log.Logger LOG -
scopeDelegate
The delegated Container Scope -
decoderFactory
Tracking all primitive decoders for the container -
encoderFactory
Tracking all primitive encoders for the container -
client
The jetty websocket client in use for this container -
internalClient
private final boolean internalClient -
endpointClientMetadataCache
Tracking for all declared Client endpoints -
sessionTracker
-
-
Constructor Details
-
ClientContainer
public ClientContainer()This is the entry point forContainerProvider.getWebSocketContainer()
-
ClientContainer
public ClientContainer(org.eclipse.jetty.client.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
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, org.eclipse.jetty.client.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
Build a ClientContainer with a specific WebSocketClient in mind.- Parameters:
client
- the WebSocketClient to use.
-
-
Method Details
-
connect
- Throws:
IOException
-
connectToServer
public javax.websocket.Session connectToServer(Class<? extends javax.websocket.Endpoint> endpointClass, javax.websocket.ClientEndpointConfig config, URI path) throws javax.websocket.DeploymentException, IOException - Specified by:
connectToServer
in interfacejavax.websocket.WebSocketContainer
- Throws:
javax.websocket.DeploymentException
IOException
-
connectToServer
public javax.websocket.Session connectToServer(Class<?> annotatedEndpointClass, URI path) throws javax.websocket.DeploymentException, IOException - Specified by:
connectToServer
in interfacejavax.websocket.WebSocketContainer
- Throws:
javax.websocket.DeploymentException
IOException
-
connectToServer
public javax.websocket.Session connectToServer(javax.websocket.Endpoint endpoint, javax.websocket.ClientEndpointConfig config, URI path) throws javax.websocket.DeploymentException, IOException - Specified by:
connectToServer
in interfacejavax.websocket.WebSocketContainer
- Throws:
javax.websocket.DeploymentException
IOException
-
connectToServer
public javax.websocket.Session connectToServer(Object endpoint, URI path) throws javax.websocket.DeploymentException, IOException - Specified by:
connectToServer
in interfacejavax.websocket.WebSocketContainer
- Throws:
javax.websocket.DeploymentException
IOException
-
doStart
- Overrides:
doStart
in classorg.eclipse.jetty.util.component.ContainerLifeCycle
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.eclipse.jetty.util.component.ContainerLifeCycle
- Throws:
Exception
-
getBufferPool
public org.eclipse.jetty.io.ByteBufferPool getBufferPool()Description copied from interface:WebSocketContainerScope
The configured Container Buffer Pool.- Specified by:
getBufferPool
in interfaceWebSocketContainerScope
- Returns:
- the buffer pool (never null)
-
getClient
-
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(Class<?> endpoint, javax.websocket.EndpointConfig config) -
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
-
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
- Specified by:
getInstalledExtensions
in interfacejavax.websocket.WebSocketContainer
-
getObjectFactory
public org.eclipse.jetty.util.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
Used inSession.getOpenSessions()
- Returns:
- the set of open sessions
-
getPolicy
Description copied from interface:WebSocketContainerScope
The policy the container is running on.- Specified by:
getPolicy
in interfaceWebSocketContainerScope
- Returns:
- the websocket policy
-
getSslContextFactory
public org.eclipse.jetty.util.ssl.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
- Specified by:
addSessionListener
in interfaceWebSocketContainerScope
-
removeSessionListener
- Specified by:
removeSessionListener
in interfaceWebSocketContainerScope
-
getSessionListeners
- Specified by:
getSessionListeners
in interfaceWebSocketContainerScope
-
newClientEndpointInstance
private EndpointInstance newClientEndpointInstance(Class<?> endpointClass, javax.websocket.ClientEndpointConfig config) -
newClientEndpointInstance
public EndpointInstance newClientEndpointInstance(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
-