public class WebSocketInboundChannelAdapter extends MessageProducerSupport implements WebSocketListener, ApplicationEventPublisherAware
MessageProducerSupport
for inbound WebSocket messages.lifecycleCondition, lifecycleLock
EXPRESSION_PARSER, logger
DEFAULT_PHASE
Constructor and Description |
---|
WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer) |
WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer,
SubProtocolHandlerRegistry protocolHandlerRegistry) |
Modifier and Type | Method and Description |
---|---|
void |
afterSessionEnded(WebSocketSession session,
CloseStatus closeStatus)
Invoked after a
WebSocketSession has ended. |
void |
afterSessionStarted(WebSocketSession session)
Invoked after a
WebSocketSession has started. |
protected void |
doStart()
Take no action by default.
|
protected void |
doStop()
Take no action by default.
|
String |
getComponentType()
Subclasses may implement this method to provide component type information.
|
List<String> |
getSubProtocols() |
boolean |
isActive() |
protected void |
onInit()
Subclasses may implement this for initialization logic.
|
void |
onMessage(WebSocketSession session,
WebSocketMessage<?> webSocketMessage)
Handle the received
WebSocketMessage . |
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 single
AbstractBrokerMessageHandler
bean for non-MESSAGE WebSocketMessage s
and to route messages with broker destinations. |
afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisher
destroy, doStop, getPhase, getRole, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stop
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getBeanName, getComponentName
public WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer)
public WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer, SubProtocolHandlerRegistry protocolHandlerRegistry)
public void setMessageConverters(List<MessageConverter> messageConverters)
messageConverters
- The message converters.public void setMergeWithDefaultConverters(boolean mergeWithDefaultConverters)
mergeWithDefaultConverters
- true to merge, false to replace.public void setPayloadType(Class<?> payloadType)
payloadType
- to convert inbound WebSocket message bodyCompositeMessageConverter
public void setUseBroker(boolean useBroker)
AbstractBrokerMessageHandler
bean for non-MESSAGE
WebSocketMessage
s
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.useBroker
- the boolean flag.public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher
in interface ApplicationEventPublisherAware
protected void onInit()
IntegrationObjectSupport
onInit
in class MessageProducerSupport
public List<String> getSubProtocols()
getSubProtocols
in interface SubProtocolCapable
public void afterSessionStarted(WebSocketSession session) throws Exception
WebSocketListener
WebSocketSession
has started.afterSessionStarted
in interface WebSocketListener
session
- the WebSocket sessionException
- the 'afterSessionStarted' Exceptionpublic void afterSessionEnded(WebSocketSession session, CloseStatus closeStatus) throws Exception
WebSocketListener
WebSocketSession
has ended.afterSessionEnded
in interface WebSocketListener
session
- the WebSocket sessioncloseStatus
- the reason why the session was closedException
- the 'afterSessionEnded' Exceptionpublic void onMessage(WebSocketSession session, WebSocketMessage<?> webSocketMessage) throws Exception
WebSocketListener
WebSocketMessage
.onMessage
in interface WebSocketListener
session
- the WebSocket sessionwebSocketMessage
- the WebSocket messageException
- the 'onMessage' Exceptionpublic String getComponentType()
IntegrationObjectSupport
getComponentType
in interface NamedComponent
getComponentType
in class IntegrationObjectSupport
protected void doStart()
MessageProducerSupport
doStart
in class MessageProducerSupport
protected void doStop()
MessageProducerSupport
doStop
in class MessageProducerSupport
public boolean isActive()
isActive
in class AbstractEndpoint