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
The MessageProducerSupport for inbound WebSocket messages.
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
     
     
  • 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
     
    protected void
     
     
     
    boolean
     
    protected void
     
    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(List<org.springframework.messaging.converter.MessageConverter> messageConverters)
    Set the message converters to use.
    void
    setPayloadType(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, getErrorMessageStrategy, 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(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(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 List<String> getSubProtocols()
      Specified by:
      getSubProtocols in interface org.springframework.web.socket.SubProtocolCapable
    • afterSessionStarted

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

      public void afterSessionEnded(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.CloseStatus closeStatus) throws 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:
      Exception - the 'afterSessionEnded' Exception
    • onMessage

      public void onMessage(org.springframework.web.socket.WebSocketSession session, org.springframework.web.socket.WebSocketMessage<?> webSocketMessage) throws 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:
      Exception - the 'onMessage' Exception
    • getComponentType

      public 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