public class WebSocketInboundChannelAdapter extends org.springframework.integration.endpoint.MessageProducerSupport implements WebSocketListener, org.springframework.context.ApplicationEventPublisherAware
lifecycleCondition, lifecycleLock| Constructor and Description |
|---|
WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer) |
WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer,
SubProtocolHandlerRegistry protocolHandlerRegistry) |
| Modifier and Type | Method and 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() |
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. |
afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getMessagingTemplate, getOutputChannel, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrackdestroy, doStop, getPhase, getRole, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, setTaskScheduler, start, stop, stopafterPropertiesSet, extractTypeIfPossible, getApplicationContext, getApplicationContextId, getBeanFactory, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getIntegrationProperty, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, toStringpublic WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer)
public WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer, SubProtocolHandlerRegistry protocolHandlerRegistry)
public void setMessageConverters(java.util.List<org.springframework.messaging.converter.MessageConverter> messageConverters)
messageConverters - The message converters.public void setMergeWithDefaultConverters(boolean mergeWithDefaultConverters)
mergeWithDefaultConverters - true to merge, false to replace.public void setPayloadType(java.lang.Class<?> payloadType)
payloadType - to convert inbound WebSocket message bodyCompositeMessageConverterpublic void setUseBroker(boolean useBroker)
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.useBroker - the boolean flag.public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAwareprotected void onInit()
onInit in class org.springframework.integration.endpoint.MessageProducerSupportpublic java.util.List<java.lang.String> getSubProtocols()
getSubProtocols in interface org.springframework.web.socket.SubProtocolCapablepublic void afterSessionStarted(org.springframework.web.socket.WebSocketSession session)
throws java.lang.Exception
WebSocketListenerWebSocketSession has started.afterSessionStarted in interface WebSocketListenersession - the WebSocket sessionjava.lang.Exception - the 'afterSessionStarted' Exceptionpublic void afterSessionEnded(org.springframework.web.socket.WebSocketSession session,
org.springframework.web.socket.CloseStatus closeStatus)
throws java.lang.Exception
WebSocketListenerWebSocketSession has ended.afterSessionEnded in interface WebSocketListenersession - the WebSocket sessioncloseStatus - the reason why the session was closedjava.lang.Exception - the 'afterSessionEnded' Exceptionpublic void onMessage(org.springframework.web.socket.WebSocketSession session,
org.springframework.web.socket.WebSocketMessage<?> webSocketMessage)
throws java.lang.Exception
WebSocketListenerWebSocketMessage.onMessage in interface WebSocketListenersession - the WebSocket sessionwebSocketMessage - the WebSocket messagejava.lang.Exception - the 'onMessage' Exceptionpublic java.lang.String getComponentType()
getComponentType in interface org.springframework.integration.support.context.NamedComponentgetComponentType in class org.springframework.integration.context.IntegrationObjectSupportprotected void doStart()
doStart in class org.springframework.integration.endpoint.MessageProducerSupportprotected void doStop()
doStop in class org.springframework.integration.endpoint.MessageProducerSupport