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.AbstractLifeCycleListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final WebSocketClientThe jetty websocket client in use for this containerprivate final DecoderFactoryTracking all primitive decoders for the containerprivate final EncoderFactoryTracking all primitive encoders for the containerprivate final Map<Class<?>, EndpointMetadata> Tracking for all declared Client endpointsprivate final booleanprivate static final org.eclipse.jetty.util.log.Loggerprivate final WebSocketContainerScopeThe delegated Container Scopeprivate final JsrSessionTrackerFields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPINGFields 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 aWebSocketContainerusing the suppliedHttpClientfor 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())protectedClientContainer(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 TypeMethodDescriptionvoidaddSessionListener(WebSocketSessionListener listener) private javax.websocket.Sessionconnect(EndpointInstance instance, URI path) javax.websocket.SessionconnectToServer(Class<?> annotatedEndpointClass, URI path) javax.websocket.SessionconnectToServer(Class<? extends javax.websocket.Endpoint> endpointClass, javax.websocket.ClientEndpointConfig config, URI path) javax.websocket.SessionconnectToServer(Object endpoint, URI path) javax.websocket.SessionconnectToServer(javax.websocket.Endpoint endpoint, javax.websocket.ClientEndpointConfig config, URI path) protected voiddoStart()protected voiddoStop()org.eclipse.jetty.io.ByteBufferPoolThe configured Container Buffer Pool.The ClassLoader used to load classes for the WebSocketSession.getClientEndpointMetadata(Class<?> endpoint, javax.websocket.EndpointConfig config) longintlongintExecutor in use by the container.Set<javax.websocket.Extension> org.eclipse.jetty.util.DecoratedObjectFactoryObject Factory used to create objects.Set<javax.websocket.Session> Used inSession.getOpenSessions()The policy the container is running on.org.eclipse.jetty.util.ssl.SslContextFactoryThe SslContextFactory in use by the container.private EndpointInstancenewClientEndpointInstance(Class<?> endpointClass, javax.websocket.ClientEndpointConfig config) newClientEndpointInstance(Object endpoint, javax.websocket.ClientEndpointConfig config) voidvoidsetAsyncSendTimeout(long ms) voidsetDefaultMaxBinaryMessageBufferSize(int max) voidsetDefaultMaxSessionIdleTimeout(long ms) voidsetDefaultMaxTextMessageBufferSize(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, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Dumpable
dumpSelfMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpableMethods inherited from interface 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 aWebSocketContainerusing the suppliedHttpClientfor 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:
connectToServerin interfacejavax.websocket.WebSocketContainer- Throws:
javax.websocket.DeploymentExceptionIOException
-
connectToServer
public javax.websocket.Session connectToServer(Class<?> annotatedEndpointClass, URI path) throws javax.websocket.DeploymentException, IOException - Specified by:
connectToServerin interfacejavax.websocket.WebSocketContainer- Throws:
javax.websocket.DeploymentExceptionIOException
-
connectToServer
public javax.websocket.Session connectToServer(javax.websocket.Endpoint endpoint, javax.websocket.ClientEndpointConfig config, URI path) throws javax.websocket.DeploymentException, IOException - Specified by:
connectToServerin interfacejavax.websocket.WebSocketContainer- Throws:
javax.websocket.DeploymentExceptionIOException
-
connectToServer
public javax.websocket.Session connectToServer(Object endpoint, URI path) throws javax.websocket.DeploymentException, IOException - Specified by:
connectToServerin interfacejavax.websocket.WebSocketContainer- Throws:
javax.websocket.DeploymentExceptionIOException
-
doStart
-
doStop
-
getBufferPool
public org.eclipse.jetty.io.ByteBufferPool getBufferPool()Description copied from interface:WebSocketContainerScopeThe configured Container Buffer Pool.- Specified by:
getBufferPoolin interfaceWebSocketContainerScope- Returns:
- the buffer pool (never null)
-
getClient
-
getClassLoader
Description copied from interface:WebSocketContainerScopeThe 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
ThreadPoolso the WebSocketSessions may be created when the ContextClassLoader is not set.- Specified by:
getClassLoaderin interfaceWebSocketContainerScope- Returns:
- the classloader.
-
getClientEndpointMetadata
public EndpointMetadata getClientEndpointMetadata(Class<?> endpoint, javax.websocket.EndpointConfig config) -
getDecoderFactory
-
getDefaultAsyncSendTimeout
public long getDefaultAsyncSendTimeout()- Specified by:
getDefaultAsyncSendTimeoutin interfacejavax.websocket.WebSocketContainer
-
getDefaultMaxBinaryMessageBufferSize
public int getDefaultMaxBinaryMessageBufferSize()- Specified by:
getDefaultMaxBinaryMessageBufferSizein interfacejavax.websocket.WebSocketContainer
-
getDefaultMaxSessionIdleTimeout
public long getDefaultMaxSessionIdleTimeout()- Specified by:
getDefaultMaxSessionIdleTimeoutin interfacejavax.websocket.WebSocketContainer
-
getDefaultMaxTextMessageBufferSize
public int getDefaultMaxTextMessageBufferSize()- Specified by:
getDefaultMaxTextMessageBufferSizein interfacejavax.websocket.WebSocketContainer
-
getEncoderFactory
-
getExecutor
Description copied from interface:WebSocketContainerScopeExecutor in use by the container.- Specified by:
getExecutorin interfaceWebSocketContainerScope- Returns:
- the Executor in use by the container.
-
getInstalledExtensions
- Specified by:
getInstalledExtensionsin interfacejavax.websocket.WebSocketContainer
-
getObjectFactory
public org.eclipse.jetty.util.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.
-
getOpenSessions
Used inSession.getOpenSessions()- Returns:
- the set of open sessions
-
getPolicy
Description copied from interface:WebSocketContainerScopeThe policy the container is running on.- Specified by:
getPolicyin interfaceWebSocketContainerScope- Returns:
- the websocket policy
-
getSslContextFactory
public org.eclipse.jetty.util.ssl.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)
-
addSessionListener
- Specified by:
addSessionListenerin interfaceWebSocketContainerScope
-
removeSessionListener
- Specified by:
removeSessionListenerin interfaceWebSocketContainerScope
-
getSessionListeners
- Specified by:
getSessionListenersin 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:
setAsyncSendTimeoutin interfacejavax.websocket.WebSocketContainer
-
setDefaultMaxBinaryMessageBufferSize
public void setDefaultMaxBinaryMessageBufferSize(int max) - Specified by:
setDefaultMaxBinaryMessageBufferSizein interfacejavax.websocket.WebSocketContainer
-
setDefaultMaxSessionIdleTimeout
public void setDefaultMaxSessionIdleTimeout(long ms) - Specified by:
setDefaultMaxSessionIdleTimeoutin interfacejavax.websocket.WebSocketContainer
-
setDefaultMaxTextMessageBufferSize
public void setDefaultMaxTextMessageBufferSize(int max) - Specified by:
setDefaultMaxTextMessageBufferSizein interfacejavax.websocket.WebSocketContainer
-