Class JettyWebSocketServerContainer
- All Implemented Interfaces:
EventListener
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
,LifeCycle.Listener
,WebSocketContainer
,WebSocketPolicy
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
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
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addMapping
(String pathSpec, Class<?> endpointClass) void
addMapping
(String pathSpec, JettyWebSocketCreator creator) void
addSessionListener
(WebSocketSessionListener listener) Register a WebSocketSessionListener with the containervoid
dump
(Appendable out, String indent) Dump this object (and children) into an Appendable using the provided indent after any new lines.ensureContainer
(jakarta.servlet.ServletContext servletContext) getContainer
(jakarta.servlet.ServletContext servletContext) The Container provided Executor.The duration that a websocket may be idle before being closed by the implementationint
The input (read from network layer) buffer size.long
Get the maximum size of a binary message during parsing.long
The maximum payload size of any WebSocket Frame which can be received.long
Get the maximum size of a text message during parsing.Get the collection of open Sessions being tracked by this containerint
The output (write to network layer) buffer size.boolean
If true, frames are automatically fragmented to respect the maximum frame size.void
Notify the Session Listeners of an event.boolean
Remove a WebSocketSessionListener from the containervoid
setAutoFragment
(boolean autoFragment) If set to true, frames are automatically fragmented to respect the maximum frame size.void
setIdleTimeout
(Duration duration) The duration that a websocket may be idle before being closed by the implementationvoid
setInputBufferSize
(int size) The input (read from network layer) buffer size.void
setMaxBinaryMessageSize
(long size) The maximum size of a binary message during parsing/generating.void
setMaxFrameSize
(long maxFrameSize) The maximum payload size of any WebSocket Frame which can be received.void
setMaxTextMessageSize
(long size) The maximum size of a text message during parsing/generating.void
setOutputBufferSize
(int size) The output (write to network layer) buffer size.boolean
upgrade
(JettyWebSocketCreator creator, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) An immediate programmatic WebSocket upgrade that does not register a mapping or create aWebSocketUpgradeFilter
.Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, doStart, doStop, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, 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.Container
getCachedBeans, getEventListeners
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle.Listener
lifeCycleFailure, lifeCycleStarted, lifeCycleStarting, lifeCycleStopped, lifeCycleStopping
-
Field Details
-
JETTY_WEBSOCKET_CONTAINER_ATTRIBUTE
-
-
Method Details
-
getContainer
public static JettyWebSocketServerContainer getContainer(jakarta.servlet.ServletContext servletContext) -
ensureContainer
public static JettyWebSocketServerContainer ensureContainer(jakarta.servlet.ServletContext servletContext) -
addMapping
-
addMapping
-
upgrade
public boolean upgrade(JettyWebSocketCreator creator, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException An immediate programmatic WebSocket upgrade that does not register a mapping or create aWebSocketUpgradeFilter
.- Parameters:
creator
- the WebSocketCreator to use.request
- the HttpServletRequest.response
- the HttpServletResponse.- Returns:
- true if the connection was successfully upgraded to WebSocket.
- Throws:
IOException
- if an I/O error occurs.
-
getExecutor
Description copied from interface:WebSocketContainer
The Container provided Executor.- Specified by:
getExecutor
in interfaceWebSocketContainer
-
addSessionListener
Description copied from interface:WebSocketContainer
Register a WebSocketSessionListener with the container- Specified by:
addSessionListener
in interfaceWebSocketContainer
- Parameters:
listener
- the listener
-
removeSessionListener
Description copied from interface:WebSocketContainer
Remove a WebSocketSessionListener from the container- Specified by:
removeSessionListener
in interfaceWebSocketContainer
- Parameters:
listener
- the listener- Returns:
- true if listener was present and removed
-
notifySessionListeners
Description copied from interface:WebSocketContainer
Notify the Session Listeners of an event.- Specified by:
notifySessionListeners
in interfaceWebSocketContainer
- Parameters:
consumer
- the consumer to call for each tracked listener
-
getOpenSessions
Description copied from interface:WebSocketContainer
Get the collection of open Sessions being tracked by this container- Specified by:
getOpenSessions
in interfaceWebSocketContainer
- Returns:
- the collection of open sessions
-
getBehavior
- Specified by:
getBehavior
in interfaceWebSocketPolicy
-
getIdleTimeout
Description copied from interface:WebSocketPolicy
The duration that a websocket may be idle before being closed by the implementation- Specified by:
getIdleTimeout
in interfaceWebSocketPolicy
- Returns:
- the timeout duration
-
getInputBufferSize
public int getInputBufferSize()Description copied from interface:WebSocketPolicy
The input (read from network layer) buffer size.This is the raw read operation buffer size, before the parsing of the websocket frames.
- Specified by:
getInputBufferSize
in interfaceWebSocketPolicy
- Returns:
- the raw network buffer input size.
-
getOutputBufferSize
public int getOutputBufferSize()Description copied from interface:WebSocketPolicy
The output (write to network layer) buffer size.This is the raw write operation buffer size and has no relationship to the websocket frame.
- Specified by:
getOutputBufferSize
in interfaceWebSocketPolicy
- Returns:
- the raw network buffer output size.
-
getMaxBinaryMessageSize
public long getMaxBinaryMessageSize()Description copied from interface:WebSocketPolicy
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
- Specified by:
getMaxBinaryMessageSize
in interfaceWebSocketPolicy
- Returns:
- the maximum size of a binary message
-
getMaxTextMessageSize
public long getMaxTextMessageSize()Description copied from interface:WebSocketPolicy
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
- Specified by:
getMaxTextMessageSize
in interfaceWebSocketPolicy
- Returns:
- the maximum size of a text message.
-
getMaxFrameSize
public long getMaxFrameSize()Description copied from interface:WebSocketPolicy
The maximum payload size of any WebSocket Frame which can be received.- Specified by:
getMaxFrameSize
in interfaceWebSocketPolicy
- Returns:
- the maximum size of a WebSocket Frame.
-
isAutoFragment
public boolean isAutoFragment()Description copied from interface:WebSocketPolicy
If true, frames are automatically fragmented to respect the maximum frame size.- Specified by:
isAutoFragment
in interfaceWebSocketPolicy
- Returns:
- whether to automatically fragment incoming WebSocket Frames.
-
setIdleTimeout
Description copied from interface:WebSocketPolicy
The duration that a websocket may be idle before being closed by the implementation- Specified by:
setIdleTimeout
in interfaceWebSocketPolicy
- Parameters:
duration
- the timeout duration (may not be null or negative)
-
setInputBufferSize
public void setInputBufferSize(int size) Description copied from interface:WebSocketPolicy
The input (read from network layer) buffer size.- Specified by:
setInputBufferSize
in interfaceWebSocketPolicy
- Parameters:
size
- the size in bytes
-
setOutputBufferSize
public void setOutputBufferSize(int size) Description copied from interface:WebSocketPolicy
The output (write to network layer) buffer size.- Specified by:
setOutputBufferSize
in interfaceWebSocketPolicy
- Parameters:
size
- the size in bytes
-
setMaxBinaryMessageSize
public void setMaxBinaryMessageSize(long size) Description copied from interface:WebSocketPolicy
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
- Specified by:
setMaxBinaryMessageSize
in interfaceWebSocketPolicy
- Parameters:
size
- the maximum allowed size of a binary message.
-
setMaxTextMessageSize
public void setMaxTextMessageSize(long size) Description copied from interface:WebSocketPolicy
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
- Specified by:
setMaxTextMessageSize
in interfaceWebSocketPolicy
- Parameters:
size
- the maximum allowed size of a text message.
-
setMaxFrameSize
public void setMaxFrameSize(long maxFrameSize) Description copied from interface:WebSocketPolicy
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
- Specified by:
setMaxFrameSize
in interfaceWebSocketPolicy
- Parameters:
maxFrameSize
- the maximum allowed size of a WebSocket Frame.
-
setAutoFragment
public void setAutoFragment(boolean autoFragment) Description copied from interface:WebSocketPolicy
If set to true, frames are automatically fragmented to respect the maximum frame size.- Specified by:
setAutoFragment
in interfaceWebSocketPolicy
- Parameters:
autoFragment
- whether to automatically fragment incoming WebSocket Frames.
-
dump
Description copied from interface:Dumpable
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.- Specified by:
dump
in interfaceDumpable
- Overrides:
dump
in classContainerLifeCycle
- Parameters:
out
- The appendable to dump toindent
- The indent to apply after any new lines.- Throws:
IOException
- if unable to write to Appendable
-