Top Fields Constructors Methods
org.eclipse.jetty.ee10.websocket.server

public Class JettyWebSocketServerContainer

extends ContainerLifeCycle
implements WebSocketContainer, Configurable, Listener
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.util.component.LifeCycle.Listener, java.util.EventListener, org.eclipse.jetty.websocket.api.Configurable, org.eclipse.jetty.websocket.api.WebSocketContainer
Imports
java.io.IOException, java.time.Duration, java.util.ArrayList, .Collection, .List, java.util.concurrent.Executor, java.util.function.Consumer, jakarta.servlet.ServletContext, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, org.eclipse.jetty.ee10.servlet.ServletContextHandler, .ServletContextRequest, .ServletContextResponse, org.eclipse.jetty.ee10.websocket.server.config.JettyWebSocketServletContainerInitializer, org.eclipse.jetty.ee10.websocket.server.internal.DelegatedServerUpgradeRequest, .DelegatedServerUpgradeResponse, .JettyServerFrameHandlerFactory, org.eclipse.jetty.ee10.websocket.servlet.WebSocketUpgradeFilter, org.eclipse.jetty.http.pathmap.PathSpec, org.eclipse.jetty.util.Blocker, org.eclipse.jetty.util.component.ContainerLifeCycle, .Dumpable, .LifeCycle, org.eclipse.jetty.websocket.api.Configurable, .Session, .WebSocketContainer, .WebSocketSessionListener, org.eclipse.jetty.websocket.common.SessionTracker, org.eclipse.jetty.websocket.core.Configuration, .WebSocketComponents, .WebSocketConstants, org.eclipse.jetty.websocket.core.exception.WebSocketException, org.eclipse.jetty.websocket.core.server.WebSocketCreator, .WebSocketMappings, .WebSocketNegotiator, .WebSocketServerComponents, org.eclipse.jetty.websocket.core.util.ReflectUtils, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private final WebSocketComponents
private final ServletContextHandler
private final Configuration.ConfigurationCustomizer
private final Executor
private final JettyServerFrameHandlerFactory
public static final String
private static final Logger
private final List<WebSocketSessionListener>
private final SessionTracker
private final WebSocketMappings

Constructor Summary

AccessConstructor and Description
pack-priv
JettyWebSocketServerContainer(ServletContextHandler contextHandler, WebSocketMappings
the WebSocketMappings that this container belongs to
webSocketMappings
,
WebSocketComponents components, Executor
the Executor to use
executor
)

Main entry point for JettyWebSocketServletContainerInitializer.

Method Summary

Modifier and TypeMethod and Description
public void
public void
addMapping(String pathSpec, final Class<?> endpointClass)

public void
addSessionListener(WebSocketSessionListener
the listener
listener
)

Implements org.eclipse.jetty.websocket.api.WebSocketContainer.addSessionListener.

Register a WebSocketSessionListener with the container

public void
dump(Appendable
The appendable to dump to
out
,
String
The indent to apply after any new lines.
indent
)

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines.

public static JettyWebSocketServerContainer
public static JettyWebSocketServerContainer
getContainer(ServletContext servletContext)

public Executor
public Duration
getIdleTimeout()

Implements org.eclipse.jetty.websocket.api.Configurable.getIdleTimeout.

The duration that a websocket may be idle before being closed by the implementation

public int
getInputBufferSize()

Implements org.eclipse.jetty.websocket.api.Configurable.getInputBufferSize.

The input (read from network layer) buffer size.

public long
getMaxBinaryMessageSize()

Implements org.eclipse.jetty.websocket.api.Configurable.getMaxBinaryMessageSize.

Get the maximum size of a binary message during parsing.

public long
getMaxFrameSize()

Implements org.eclipse.jetty.websocket.api.Configurable.getMaxFrameSize.

The maximum payload size of any WebSocket Frame which can be received.

public int
getMaxOutgoingFrames()

Implements org.eclipse.jetty.websocket.api.Configurable.getMaxOutgoingFrames.

Get the maximum number of data frames allowed to be waiting to be sent at any one time.

public long
getMaxTextMessageSize()

Implements org.eclipse.jetty.websocket.api.Configurable.getMaxTextMessageSize.

Get the maximum size of a text message during parsing.

public Collection<Session>
getOpenSessions()

Implements org.eclipse.jetty.websocket.api.WebSocketContainer.getOpenSessions.

Get the collection of open Sessions being tracked by this container

public int
getOutputBufferSize()

Implements org.eclipse.jetty.websocket.api.Configurable.getOutputBufferSize.

The output (write to network layer) buffer size.

public boolean
isAutoFragment()

Implements org.eclipse.jetty.websocket.api.Configurable.isAutoFragment.

If true, frames are automatically fragmented to respect the maximum frame size.

public void
notifySessionListeners(Consumer<WebSocketSessionListener>
the consumer to call for each tracked listener
consumer
)

Implements org.eclipse.jetty.websocket.api.WebSocketContainer.notifySessionListeners.

Notify the Session Listeners of an event.

public boolean
removeSessionListener(WebSocketSessionListener
the listener
listener
)

Implements org.eclipse.jetty.websocket.api.WebSocketContainer.removeSessionListener.

Remove a WebSocketSessionListener from the container

public void
setAutoFragment(boolean
whether to automatically fragment incoming WebSocket Frames.
autoFragment
)

Implements org.eclipse.jetty.websocket.api.Configurable.setAutoFragment.

If set to true, frames are automatically fragmented to respect the maximum frame size.

public void
setIdleTimeout(Duration
the timeout duration (may not be null or negative)
duration
)

Implements org.eclipse.jetty.websocket.api.Configurable.setIdleTimeout.

The duration that a websocket may be idle before being closed by the implementation

public void
setInputBufferSize(int
the size in bytes
size
)

Implements org.eclipse.jetty.websocket.api.Configurable.setInputBufferSize.

The input (read from network layer) buffer size.

public void
setMaxBinaryMessageSize(long
the maximum allowed size of a binary message.
size
)

Implements org.eclipse.jetty.websocket.api.Configurable.setMaxBinaryMessageSize.

The maximum size of a binary message during parsing/generating.

public void
setMaxFrameSize(long
the maximum allowed size of a WebSocket Frame.
maxFrameSize
)

Implements org.eclipse.jetty.websocket.api.Configurable.setMaxFrameSize.

The maximum payload size of any WebSocket Frame which can be received.

public void
setMaxOutgoingFrames(int
the max number of frames.
maxOutgoingFrames
)

Implements org.eclipse.jetty.websocket.api.Configurable.setMaxOutgoingFrames.

Set the maximum number of data frames allowed to be waiting to be sent at any one time.

public void
setMaxTextMessageSize(long
the maximum allowed size of a text message.
size
)

Implements org.eclipse.jetty.websocket.api.Configurable.setMaxTextMessageSize.

The maximum size of a text message during parsing/generating.

public void
setOutputBufferSize(int
the size in bytes
size
)

Implements org.eclipse.jetty.websocket.api.Configurable.setOutputBufferSize.

The output (write to network layer) buffer size.

public boolean

Returns:

true if the connection could be upgraded or an error was sent.
upgrade
(JettyWebSocketCreator
the WebSocketCreator to use.
creator
,
HttpServletRequest
the HttpServletRequest.
request
,
HttpServletResponse
the HttpServletResponse.
response
)

An immediate programmatic WebSocket upgrade that does not register a mapping or create a WebSocketUpgradeFilter.

Inherited from org.eclipse.jetty.util.component.ContainerLifeCycle:
addBeanaddBeanaddEventListeneraddManagedcontainsdestroydoStartdoStopdumpdumpdumpObjectsdumpStdErrgetBeangetBeansgetBeansgetContainedBeansgetContainedBeansisAutoisManagedisUnmanagedmanageremoveBeanremoveBeansremoveEventListenersetBeansstartstopunmanageupdateBeanupdateBeanupdateBeansupdateBeans

Field Detail

componentsback to summary
private final WebSocketComponents components
contextHandlerback to summary
private final ServletContextHandler contextHandler
customizerback to summary
private final Configuration.ConfigurationCustomizer customizer
executorback to summary
private final Executor executor
frameHandlerFactoryback to summary
private final JettyServerFrameHandlerFactory frameHandlerFactory
JETTY_WEBSOCKET_CONTAINER_ATTRIBUTEback to summary
public static final String JETTY_WEBSOCKET_CONTAINER_ATTRIBUTE
LOGback to summary
private static final Logger LOG

Hides org.eclipse.jetty.util.component.ContainerLifeCycle.LOG.

sessionListenersback to summary
private final List<WebSocketSessionListener> sessionListeners
sessionTrackerback to summary
private final SessionTracker sessionTracker
webSocketMappingsback to summary
private final WebSocketMappings webSocketMappings

Constructor Detail

JettyWebSocketServerContainerback to summary
pack-priv JettyWebSocketServerContainer(ServletContextHandler contextHandler, WebSocketMappings webSocketMappings, WebSocketComponents components, Executor executor)

Main entry point for JettyWebSocketServletContainerInitializer.

Parameters
webSocketMappings:WebSocketMappings

the WebSocketMappings that this container belongs to

executor:Executor

the Executor to use

Method Detail

addMappingback to summary
public void addMapping(String pathSpec, JettyWebSocketCreator creator)
addMappingback to summary
public void addMapping(String pathSpec, final Class<?> endpointClass)
addSessionListenerback to summary
public void addSessionListener(WebSocketSessionListener listener)

Implements org.eclipse.jetty.websocket.api.WebSocketContainer.addSessionListener.

Doc from org.eclipse.jetty.websocket.api.WebSocketContainer.addSessionListener.

Register a WebSocketSessionListener with the container

Parameters
listener:WebSocketSessionListener

the listener

Annotations
@Override
dumpback to summary
public void dump(Appendable out, String indent) throws IOException

Overrides org.eclipse.jetty.util.component.ContainerLifeCycle.dump.

Implements org.eclipse.jetty.util.component.Dumpable.dump.

Doc from org.eclipse.jetty.util.component.Dumpable.dump.

Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.

Parameters
out:Appendable

The appendable to dump to

indent:String

The indent to apply after any new lines.

Annotations
@Override
Exceptions
IOException:
if unable to write to Appendable
ensureContainerback to summary
public static JettyWebSocketServerContainer ensureContainer(ServletContext servletContext)
getContainerback to summary
public static JettyWebSocketServerContainer getContainer(ServletContext servletContext)
getExecutorback to summary
public Executor getExecutor()

Implements org.eclipse.jetty.websocket.api.WebSocketContainer.getExecutor.

Doc from org.eclipse.jetty.websocket.api.WebSocketContainer.getExecutor.

The Container provided Executor.

Annotations
@Override
getIdleTimeoutback to summary
public Duration getIdleTimeout()

Implements org.eclipse.jetty.websocket.api.Configurable.getIdleTimeout.

Doc from org.eclipse.jetty.websocket.api.Configurable.getIdleTimeout.

The duration that a websocket may be idle before being closed by the implementation

Returns:Duration

the timeout duration

Annotations
@Override
getInputBufferSizeback to summary
public int getInputBufferSize()

Implements org.eclipse.jetty.websocket.api.Configurable.getInputBufferSize.

Doc from org.eclipse.jetty.websocket.api.Configurable.getInputBufferSize.

The input (read from network layer) buffer size.

This is the raw read operation buffer size, before the parsing of the websocket frames.

Returns:int

the raw network buffer input size.

Annotations
@Override
getMaxBinaryMessageSizeback to summary
public long getMaxBinaryMessageSize()

Implements org.eclipse.jetty.websocket.api.Configurable.getMaxBinaryMessageSize.

Doc from org.eclipse.jetty.websocket.api.Configurable.getMaxBinaryMessageSize.

Get the maximum size of a binary message during parsing.

This is a memory conservation option, memory over this limit will not be allocated by Jetty for handling binary messages. This applies to individual frames, whole message handling, and partial message handling.

Binary messages over this maximum will result in a close code 1009 StatusCode#MESSAGE_TOO_LARGE

Returns:long

the maximum size of a binary message

Annotations
@Override
getMaxFrameSizeback to summary
public long getMaxFrameSize()

Implements org.eclipse.jetty.websocket.api.Configurable.getMaxFrameSize.

Doc from org.eclipse.jetty.websocket.api.Configurable.getMaxFrameSize.

The maximum payload size of any WebSocket Frame which can be received.

Returns:long

the maximum size of a WebSocket Frame.

Annotations
@Override
getMaxOutgoingFramesback to summary
public int getMaxOutgoingFrames()

Implements org.eclipse.jetty.websocket.api.Configurable.getMaxOutgoingFrames.

Doc from org.eclipse.jetty.websocket.api.Configurable.getMaxOutgoingFrames.

Get the maximum number of data frames allowed to be waiting to be sent at any one time. The default value is -1, this indicates there is no limit on how many frames can be queued to be sent by the implementation. If the limit is exceeded, subsequent frames sent are failed with a java.nio.channels.WritePendingException but the connection is not failed and will remain open.

Returns:int

the max number of frames.

Annotations
@Override
getMaxTextMessageSizeback to summary
public long getMaxTextMessageSize()

Implements org.eclipse.jetty.websocket.api.Configurable.getMaxTextMessageSize.

Doc from org.eclipse.jetty.websocket.api.Configurable.getMaxTextMessageSize.

Get the maximum size of a text message during parsing.

This is a memory conservation option, memory over this limit will not be allocated by Jetty for handling text messages. This applies to individual frames, whole message handling, and partial message handling.

Text messages over this maximum will result in a close code 1009 StatusCode#MESSAGE_TOO_LARGE

Returns:long

the maximum size of a text message.

Annotations
@Override
getOpenSessionsback to summary
public Collection<Session> getOpenSessions()

Implements org.eclipse.jetty.websocket.api.WebSocketContainer.getOpenSessions.

Doc from org.eclipse.jetty.websocket.api.WebSocketContainer.getOpenSessions.

Get the collection of open Sessions being tracked by this container

Returns:Collection<Session>

the collection of open sessions

Annotations
@Override
getOutputBufferSizeback to summary
public int getOutputBufferSize()

Implements org.eclipse.jetty.websocket.api.Configurable.getOutputBufferSize.

Doc from org.eclipse.jetty.websocket.api.Configurable.getOutputBufferSize.

The output (write to network layer) buffer size.

This is the raw write operation buffer size and has no relationship to the websocket frame.

Returns:int

the raw network buffer output size.

Annotations
@Override
isAutoFragmentback to summary
public boolean isAutoFragment()

Implements org.eclipse.jetty.websocket.api.Configurable.isAutoFragment.

Doc from org.eclipse.jetty.websocket.api.Configurable.isAutoFragment.

If true, frames are automatically fragmented to respect the maximum frame size.

Returns:boolean

whether to automatically fragment incoming WebSocket Frames.

Annotations
@Override
notifySessionListenersback to summary
public void notifySessionListeners(Consumer<WebSocketSessionListener> consumer)

Implements org.eclipse.jetty.websocket.api.WebSocketContainer.notifySessionListeners.

Doc from org.eclipse.jetty.websocket.api.WebSocketContainer.notifySessionListeners.

Notify the Session Listeners of an event.

Parameters
consumer:Consumer<WebSocketSessionListener>

the consumer to call for each tracked listener

Annotations
@Override
removeSessionListenerback to summary
public boolean removeSessionListener(WebSocketSessionListener listener)

Implements org.eclipse.jetty.websocket.api.WebSocketContainer.removeSessionListener.

Doc from org.eclipse.jetty.websocket.api.WebSocketContainer.removeSessionListener.

Remove a WebSocketSessionListener from the container

Parameters
listener:WebSocketSessionListener

the listener

Returns:boolean

true if listener was present and removed

Annotations
@Override
setAutoFragmentback to summary
public void setAutoFragment(boolean autoFragment)

Implements org.eclipse.jetty.websocket.api.Configurable.setAutoFragment.

Doc from org.eclipse.jetty.websocket.api.Configurable.setAutoFragment.

If set to true, frames are automatically fragmented to respect the maximum frame size.

Parameters
autoFragment:boolean

whether to automatically fragment incoming WebSocket Frames.

Annotations
@Override
setIdleTimeoutback to summary
public void setIdleTimeout(Duration duration)

Implements org.eclipse.jetty.websocket.api.Configurable.setIdleTimeout.

Doc from org.eclipse.jetty.websocket.api.Configurable.setIdleTimeout.

The duration that a websocket may be idle before being closed by the implementation

Parameters
duration:Duration

the timeout duration (may not be null or negative)

Annotations
@Override
setInputBufferSizeback to summary
public void setInputBufferSize(int size)

Implements org.eclipse.jetty.websocket.api.Configurable.setInputBufferSize.

Doc from org.eclipse.jetty.websocket.api.Configurable.setInputBufferSize.

The input (read from network layer) buffer size.

Parameters
size:int

the size in bytes

Annotations
@Override
setMaxBinaryMessageSizeback to summary
public void setMaxBinaryMessageSize(long size)

Implements org.eclipse.jetty.websocket.api.Configurable.setMaxBinaryMessageSize.

Doc from org.eclipse.jetty.websocket.api.Configurable.setMaxBinaryMessageSize.

The maximum size of a binary message during parsing/generating.

Binary messages over this maximum will result in a close code 1009 StatusCode#MESSAGE_TOO_LARGE

Parameters
size:long

the maximum allowed size of a binary message.

Annotations
@Override
setMaxFrameSizeback to summary
public void setMaxFrameSize(long maxFrameSize)

Implements org.eclipse.jetty.websocket.api.Configurable.setMaxFrameSize.

Doc from org.eclipse.jetty.websocket.api.Configurable.setMaxFrameSize.

The maximum payload size of any WebSocket Frame which can be received.

WebSocket Frames over this maximum will result in a close code 1009 StatusCode#MESSAGE_TOO_LARGE

Parameters
maxFrameSize:long

the maximum allowed size of a WebSocket Frame.

Annotations
@Override
setMaxOutgoingFramesback to summary
public void setMaxOutgoingFrames(int maxOutgoingFrames)

Implements org.eclipse.jetty.websocket.api.Configurable.setMaxOutgoingFrames.

Doc from org.eclipse.jetty.websocket.api.Configurable.setMaxOutgoingFrames.

Set the maximum number of data frames allowed to be waiting to be sent at any one time. The default value is -1, this indicates there is no limit on how many frames can be queued to be sent by the implementation. If the limit is exceeded, subsequent frames sent are failed with a java.nio.channels.WritePendingException but the connection is not failed and will remain open.

Parameters
maxOutgoingFrames:int

the max number of frames.

Annotations
@Override
setMaxTextMessageSizeback to summary
public void setMaxTextMessageSize(long size)

Implements org.eclipse.jetty.websocket.api.Configurable.setMaxTextMessageSize.

Doc from org.eclipse.jetty.websocket.api.Configurable.setMaxTextMessageSize.

The maximum size of a text message during parsing/generating.

Text messages over this maximum will result in a close code 1009 StatusCode#MESSAGE_TOO_LARGE

Parameters
size:long

the maximum allowed size of a text message.

Annotations
@Override
setOutputBufferSizeback to summary
public void setOutputBufferSize(int size)

Implements org.eclipse.jetty.websocket.api.Configurable.setOutputBufferSize.

Doc from org.eclipse.jetty.websocket.api.Configurable.setOutputBufferSize.

The output (write to network layer) buffer size.

Parameters
size:int

the size in bytes

Annotations
@Override
upgradeback to summary
public boolean upgrade(JettyWebSocketCreator creator, HttpServletRequest request, HttpServletResponse response) throws IOException

An immediate programmatic WebSocket upgrade that does not register a mapping or create a WebSocketUpgradeFilter.

A return value of true means the connection was Upgraded to WebSocket or an error response is being generated. A return value of false means that it was a bad upgrade request and couldn't be upgraded to WebSocket and the caller is responsible for generating the response.

Parameters
creator:JettyWebSocketCreator

the WebSocketCreator to use.

request:HttpServletRequest

the HttpServletRequest.

response:HttpServletResponse

the HttpServletResponse.

Returns:boolean

true if the connection could be upgraded or an error was sent.

Exceptions
IOException:
if an I/O error occurs.