Class WebSocketInboundChannelAdapter

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
org.springframework.integration.websocket.inbound.WebSocketInboundChannelAdapter
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.SmartInitializingSingleton, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationEventPublisherAware, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, org.springframework.integration.context.ExpressionCapable, org.springframework.integration.core.MessageProducer, org.springframework.integration.IntegrationPattern, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.ManageableLifecycle, org.springframework.integration.support.management.ManageableSmartLifecycle, org.springframework.integration.support.management.TrackableComponent, WebSocketListener, org.springframework.web.socket.SubProtocolCapable

public class WebSocketInboundChannelAdapter
extends org.springframework.integration.endpoint.MessageProducerSupport
implements WebSocketListener, org.springframework.context.ApplicationEventPublisherAware
Since:
4.1
  • Field Summary

    Fields inherited from class org.springframework.integration.endpoint.AbstractEndpoint

    lifecycleCondition, lifecycleLock

    Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport

    EXPRESSION_PARSER, logger

    Fields inherited from interface org.springframework.context.SmartLifecycle

    DEFAULT_PHASE
  • Constructor Summary

    Constructors 
    Constructor Description
    WebSocketInboundChannelAdapter​(IntegrationWebSocketContainer webSocketContainer)  
    WebSocketInboundChannelAdapter​(IntegrationWebSocketContainer webSocketContainer, SubProtocolHandlerRegistry protocolHandlerRegistry)  
  • Method Summary

    Modifier and Type Method Description
    void afterSessionEnded​(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus closeStatus)
    Invoked after a WebSocketSession has ended.
    void afterSessionStarted​(org.springframework.web.socket.WebSocketSession session)
    Invoked after a WebSocketSession has started.
    protected void doStart()  
    protected void doStop()  
    java.lang.String getComponentType()  
    java.util.List<java.lang.String> getSubProtocols()  
    boolean isActive()  
    protected void onInit()  
    void onMessage​(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.WebSocketMessage<?> webSocketMessage)
    Handle the received WebSocketMessage.
    void setApplicationEventPublisher​(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)  
    void setMergeWithDefaultConverters​(boolean mergeWithDefaultConverters)
    Flag which determines if the default converters should be available after custom converters.
    void setMessageConverters​(java.util.List<org.springframework.messaging.converter.MessageConverter> messageConverters)
    Set the message converters to use.
    void setPayloadType​(java.lang.Class<?> payloadType)
    Set the type for target message payload to convert the WebSocket message body to.
    void setUseBroker​(boolean useBroker)
    Specify if this adapter should use an existing single AbstractBrokerMessageHandler bean for non-MESSAGE WebSocketMessages and to route messages with broker destinations.

    Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport

    afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisher

    Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint

    destroy, doStop, getPhase, getRole, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop

    Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport

    afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.integration.support.context.NamedComponent

    getBeanName, getComponentName
  • Constructor Details

  • Method Details

    • setMessageConverters

      public void setMessageConverters​(java.util.List<org.springframework.messaging.converter.MessageConverter> messageConverters)
      Set the message converters to use. These converters are used to convert the message to send for appropriate internal subProtocols type.
      Parameters:
      messageConverters - The message converters.
    • setMergeWithDefaultConverters

      public void setMergeWithDefaultConverters​(boolean mergeWithDefaultConverters)
      Flag which determines if the default converters should be available after custom converters.
      Parameters:
      mergeWithDefaultConverters - true to merge, false to replace.
    • setPayloadType

      public void setPayloadType​(java.lang.Class<?> payloadType)
      Set the type for target message payload to convert the WebSocket message body to.
      Parameters:
      payloadType - to convert inbound WebSocket message body
      See Also:
      CompositeMessageConverter
    • setUseBroker

      public void setUseBroker​(boolean useBroker)
      Specify if this adapter should use an existing single AbstractBrokerMessageHandler bean for non-MESSAGE WebSocketMessages and to route messages with broker destinations. Since only single AbstractBrokerMessageHandler bean is allowed in the current application context, the algorithm to lookup the former by type, rather than applying the bean reference. This is used only on server side and is ignored from client side.
      Parameters:
      useBroker - the boolean flag.
    • setApplicationEventPublisher

      public void setApplicationEventPublisher​(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
      Specified by:
      setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware
    • onInit

      protected void onInit()
      Overrides:
      onInit in class org.springframework.integration.endpoint.MessageProducerSupport
    • getSubProtocols

      public java.util.List<java.lang.String> getSubProtocols()
      Specified by:
      getSubProtocols in interface org.springframework.web.socket.SubProtocolCapable
    • afterSessionStarted

      public void afterSessionStarted​(org.springframework.web.socket.WebSocketSession session) throws java.lang.Exception
      Description copied from interface: WebSocketListener
      Invoked after a WebSocketSession has started.
      Specified by:
      afterSessionStarted in interface WebSocketListener
      Parameters:
      session - the WebSocket session
      Throws:
      java.lang.Exception - the 'afterSessionStarted' Exception
    • afterSessionEnded

      public void afterSessionEnded​(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus closeStatus) throws java.lang.Exception
      Description copied from interface: WebSocketListener
      Invoked after a WebSocketSession has ended.
      Specified by:
      afterSessionEnded in interface WebSocketListener
      Parameters:
      session - the WebSocket session
      closeStatus - the reason why the session was closed
      Throws:
      java.lang.Exception - the 'afterSessionEnded' Exception
    • onMessage

      public void onMessage​(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.WebSocketMessage<?> webSocketMessage) throws java.lang.Exception
      Description copied from interface: WebSocketListener
      Handle the received WebSocketMessage.
      Specified by:
      onMessage in interface WebSocketListener
      Parameters:
      session - the WebSocket session
      webSocketMessage - the WebSocket message
      Throws:
      java.lang.Exception - the 'onMessage' Exception
    • getComponentType

      public java.lang.String getComponentType()
      Specified by:
      getComponentType in interface org.springframework.integration.support.context.NamedComponent
      Overrides:
      getComponentType in class org.springframework.integration.context.IntegrationObjectSupport
    • doStart

      protected void doStart()
      Overrides:
      doStart in class org.springframework.integration.endpoint.MessageProducerSupport
    • doStop

      protected void doStop()
      Overrides:
      doStop in class org.springframework.integration.endpoint.MessageProducerSupport
    • isActive

      public boolean isActive()
      Overrides:
      isActive in class org.springframework.integration.endpoint.AbstractEndpoint