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, lifecycleLockFields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer) WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer, SubProtocolHandlerRegistry protocolHandlerRegistry) -
Method Summary
Modifier and TypeMethodDescriptionvoidafterSessionEnded(WebSocketSession session, CloseStatus closeStatus) Invoked after aWebSocketSessionhas ended.voidafterSessionStarted(WebSocketSession session) Invoked after aWebSocketSessionhas started.protected voiddoStart()Take no action by default.protected voiddoStop()Take no action by default.Subclasses may implement this method to provide component type information.booleanisActive()protected voidonInit()Subclasses may implement this for initialization logic.voidonMessage(WebSocketSession session, WebSocketMessage<?> webSocketMessage) Handle the receivedWebSocketMessage.voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) voidsetMergeWithDefaultConverters(boolean mergeWithDefaultConverters) Flag which determines if the default converters should be available after custom converters.voidsetMessageConverters(List<MessageConverter> messageConverters) Set the message converters to use.voidsetPayloadType(Class<?> payloadType) Set the type for target message payload to convert the WebSocket message body to.voidsetUseBroker(boolean useBroker) Specify if this adapter should use an existing singleAbstractBrokerMessageHandlerbean fornon-MESSAGEWebSocketMessages 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, subscribeToPublisherMethods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
destroy, doStop, getPhase, getRole, isAutoStartup, isRunning, setAutoStartup, setPhase, setRole, start, stop, stopMethods 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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.integration.support.management.IntegrationManagement
destroy, getManagedName, getManagedType, getOverrides, getThisAs, isLoggingEnabled, registerMetricsCaptor, setLoggingEnabled, setManagedName, setManagedTypeMethods 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 singleAbstractBrokerMessageHandlerbean fornon-MESSAGEWebSocketMessages and to route messages with broker destinations. Since only singleAbstractBrokerMessageHandlerbean 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:
setApplicationEventPublisherin interfaceApplicationEventPublisherAware
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupportSubclasses may implement this for initialization logic.- Overrides:
onInitin classMessageProducerSupport
-
getSubProtocols
- Specified by:
getSubProtocolsin interfaceSubProtocolCapable
-
afterSessionStarted
Description copied from interface:WebSocketListenerInvoked after aWebSocketSessionhas started.- Specified by:
afterSessionStartedin interfaceWebSocketListener- Parameters:
session- the WebSocket session
-
afterSessionEnded
Description copied from interface:WebSocketListenerInvoked after aWebSocketSessionhas ended.- Specified by:
afterSessionEndedin interfaceWebSocketListener- Parameters:
session- the WebSocket sessioncloseStatus- the reason why the session was closed
-
onMessage
Description copied from interface:WebSocketListenerHandle the receivedWebSocketMessage.- Specified by:
onMessagein interfaceWebSocketListener- Parameters:
session- the WebSocket sessionwebSocketMessage- the WebSocket message
-
getComponentType
Description copied from class:IntegrationObjectSupportSubclasses may implement this method to provide component type information.- Specified by:
getComponentTypein interfaceNamedComponent- Overrides:
getComponentTypein classIntegrationObjectSupport
-
doStart
protected void doStart()Description copied from class:MessageProducerSupportTake no action by default. Subclasses may override this if they need lifecycle-managed behavior. Protected by 'lifecycleLock'.- Overrides:
doStartin classMessageProducerSupport
-
doStop
protected void doStop()Description copied from class:MessageProducerSupportTake no action by default. Subclasses may override this if they need lifecycle-managed behavior.- Overrides:
doStopin classMessageProducerSupport
-
isActive
public boolean isActive()- Overrides:
isActivein classAbstractEndpoint
-