Class IntegrationWebSocketContainer

java.lang.Object
org.springframework.integration.websocket.IntegrationWebSocketContainer
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean
Direct Known Subclasses:
ClientWebSocketContainer, ServerWebSocketContainer

public abstract class IntegrationWebSocketContainer extends Object implements org.springframework.beans.factory.DisposableBean
The high-level 'connection factory pattern' contract over low-level Web-Socket configuration.

Provides the composition for the internal WebSocketHandler implementation, which is used with native Web-Socket containers.

Collects established WebSocketSessions, which can be accessed using getSession(String).

Can accept the WebSocketListener to delegate WebSocketSession events from the internal IntegrationWebSocketContainer.IntegrationWebSocketHandler.

Supported sub-protocols can be configured, but SubProtocolCapable.getSubProtocols() have a precedent.

Since:
4.1
See Also:
  • Field Details

    • DEFAULT_SEND_TIME_LIMIT

      public static final int DEFAULT_SEND_TIME_LIMIT
      See Also:
    • DEFAULT_SEND_BUFFER_SIZE

      public static final int DEFAULT_SEND_BUFFER_SIZE
      See Also:
    • logger

      protected final org.apache.commons.logging.Log logger
    • sessions

      protected final Map<String,org.springframework.web.socket.WebSocketSession> sessions
  • Constructor Details

    • IntegrationWebSocketContainer

      public IntegrationWebSocketContainer()
  • Method Details

    • setSendTimeLimit

      public void setSendTimeLimit(int sendTimeLimit)
    • setSendBufferSizeLimit

      public void setSendBufferSizeLimit(int sendBufferSizeLimit)
    • setSendBufferOverflowStrategy

      public void setSendBufferOverflowStrategy(@Nullable org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorator.OverflowStrategy overflowStrategy)
      Set the send buffer overflow strategy.

      Concurrently generated outbound messages are buffered if sending is slow. This strategy determines the behavior when the buffer has reached the limit configured with setSendBufferSizeLimit(int).

      Parameters:
      overflowStrategy - The ConcurrentWebSocketSessionDecorator.OverflowStrategy to use.
      Since:
      5.5.19
      See Also:
      • ConcurrentWebSocketSessionDecorator
    • setMessageListener

      public void setMessageListener(WebSocketListener messageListener)
    • setSupportedProtocols

      public void setSupportedProtocols(String... protocols)
    • addSupportedProtocols

      public void addSupportedProtocols(String... protocols)
    • setWebSocketHandler

      protected void setWebSocketHandler(org.springframework.web.socket.WebSocketHandler handler)
      Replace the default WebSocketHandler with the one provided here, e.g. via decoration factories.
      Parameters:
      handler - the actual WebSocketHandler to replace.
      Since:
      5.5.18
    • getWebSocketHandler

      public org.springframework.web.socket.WebSocketHandler getWebSocketHandler()
    • getSubProtocols

      public List<String> getSubProtocols()
    • getSessions

      public Map<String,org.springframework.web.socket.WebSocketSession> getSessions()
    • getSession

      public org.springframework.web.socket.WebSocketSession getSession(String sessionId)
    • closeSession

      public void closeSession(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus closeStatus) throws Exception
      Throws:
      Exception
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean