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:
Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,SmartInitializingSingleton
,ApplicationContextAware
,ApplicationEventPublisherAware
,Lifecycle
,Phased
,SmartLifecycle
,ExpressionCapable
,MessageProducer
,IntegrationPattern
,NamedComponent
,IntegrationInboundManagement
,IntegrationManagement
,ManageableLifecycle
,ManageableSmartLifecycle
,TrackableComponent
,WebSocketListener
,SubProtocolCapable
public class WebSocketInboundChannelAdapter
extends MessageProducerSupport
implements WebSocketListener, ApplicationEventPublisherAware
The
MessageProducerSupport
for inbound WebSocket messages.- Since:
- 4.1
- Author:
- Artem Bilan
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
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.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionWebSocketInboundChannelAdapter
(IntegrationWebSocketContainer webSocketContainer) WebSocketInboundChannelAdapter
(IntegrationWebSocketContainer webSocketContainer, SubProtocolHandlerRegistry protocolHandlerRegistry) -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterSessionEnded
(WebSocketSession session, CloseStatus closeStatus) Invoked after aWebSocketSession
has ended.void
afterSessionStarted
(WebSocketSession session) Invoked after aWebSocketSession
has started.protected void
doStart()
Take no action by default.protected void
doStop()
Take no action by default.Subclasses may implement this method to provide component type information.boolean
isActive()
protected void
onInit()
Subclasses may implement this for initialization logic.void
onMessage
(WebSocketSession session, WebSocketMessage<?> webSocketMessage) Handle the receivedWebSocketMessage
.void
setApplicationEventPublisher
(ApplicationEventPublisher applicationEventPublisher) void
setMergeWithDefaultConverters
(boolean mergeWithDefaultConverters) Flag which determines if the default converters should be available after custom converters.void
setMessageConverters
(List<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 singleAbstractBrokerMessageHandler
bean fornon-MESSAGE
WebSocketMessage
s and to route messages with broker destinations.Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport
afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, isObserved, registerObservationRegistry, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setObservationConvention, 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, 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.management.IntegrationManagement
destroy, getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedType
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
WebSocketInboundChannelAdapter
-
WebSocketInboundChannelAdapter
public WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer, SubProtocolHandlerRegistry protocolHandlerRegistry)
-
-
Method Details
-
setMessageConverters
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
Set the type for target message payload to convert the WebSocket message body to.- Parameters:
payloadType
- to convert inbound WebSocket message body- See Also:
-
setUseBroker
public void setUseBroker(boolean useBroker) Specify if this adapter should use an existing singleAbstractBrokerMessageHandler
bean fornon-MESSAGE
WebSocketMessage
s and to route messages with broker destinations. Since only singleAbstractBrokerMessageHandler
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
- Specified by:
setApplicationEventPublisher
in interfaceApplicationEventPublisherAware
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classMessageProducerSupport
-
getSubProtocols
- Specified by:
getSubProtocols
in interfaceSubProtocolCapable
-
afterSessionStarted
Description copied from interface:WebSocketListener
Invoked after aWebSocketSession
has started.- Specified by:
afterSessionStarted
in interfaceWebSocketListener
- Parameters:
session
- the WebSocket session
-
afterSessionEnded
Description copied from interface:WebSocketListener
Invoked after aWebSocketSession
has ended.- Specified by:
afterSessionEnded
in interfaceWebSocketListener
- Parameters:
session
- the WebSocket sessioncloseStatus
- the reason why the session was closed
-
onMessage
Description copied from interface:WebSocketListener
Handle the receivedWebSocketMessage
.- Specified by:
onMessage
in interfaceWebSocketListener
- Parameters:
session
- the WebSocket sessionwebSocketMessage
- the WebSocket message
-
getComponentType
Description copied from class:IntegrationObjectSupport
Subclasses may implement this method to provide component type information.- Specified by:
getComponentType
in interfaceNamedComponent
- Overrides:
getComponentType
in classIntegrationObjectSupport
-
doStart
protected void doStart()Description copied from class:MessageProducerSupport
Take no action by default. Subclasses may override this if they need lifecycle-managed behavior. Protected by 'lifecycleLock'.- Overrides:
doStart
in classMessageProducerSupport
-
doStop
protected void doStop()Description copied from class:MessageProducerSupport
Take no action by default. Subclasses may override this if they need lifecycle-managed behavior.- Overrides:
doStop
in classMessageProducerSupport
-
isActive
public boolean isActive()- Overrides:
isActive
in classAbstractEndpoint
-