Class ApplicationEventListeningMessageProducer
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
org.springframework.integration.endpoint.ExpressionMessageProducerSupport
org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer
- All Implemented Interfaces:
EventListener
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,SmartInitializingSingleton
,ApplicationContextAware
,ApplicationListener<ApplicationEvent>
,GenericApplicationListener
,SmartApplicationListener
,Lifecycle
,Phased
,SmartLifecycle
,Ordered
,ExpressionCapable
,MessageProducer
,IntegrationPattern
,NamedComponent
,IntegrationInboundManagement
,IntegrationManagement
,ManageableLifecycle
,ManageableSmartLifecycle
,TrackableComponent
public class ApplicationEventListeningMessageProducer
extends ExpressionMessageProducerSupport
implements GenericApplicationListener
An inbound Channel Adapter that implements
GenericApplicationListener
and
passes Spring ApplicationEvents
within messages.
If a payloadExpression
is provided, it will be evaluated against
the ApplicationEvent instance to create the Message payload. Otherwise, the event itself will be the payload.- Author:
- Mark Fisher, Artem Bilan, Gary Russell
- See Also:
-
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.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doStop()
Take no action by default.Subclasses may implement this method to provide component type information.int
getOrder()
void
protected void
onInit()
Subclasses may implement this for initialization logic.final void
setEventTypes
(Class<?>... eventTypes) Set the list of event types (classes that extend ApplicationEvent) that this adapter should send to the message channel.boolean
supportsEventType
(ResolvableType eventType) boolean
supportsSourceType
(Class<?> sourceType) Methods inherited from class org.springframework.integration.endpoint.ExpressionMessageProducerSupport
evaluatePayloadExpression, setIntegrationEvaluationContext, setPayloadExpression, setPayloadExpressionString
Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport
afterSingletonsInstantiated, buildErrorMessage, doStart, 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, isActive, 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.context.ApplicationListener
supportsAsyncExecution
Methods inherited from interface org.springframework.context.event.GenericApplicationListener
supportsEventType
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
Methods inherited from interface org.springframework.context.event.SmartApplicationListener
getListenerId
-
Constructor Details
-
ApplicationEventListeningMessageProducer
public ApplicationEventListeningMessageProducer()Construct an instance.
-
-
Method Details
-
setEventTypes
Set the list of event types (classes that extend ApplicationEvent) that this adapter should send to the message channel. By default, all event types will be sent. In addition, this method re-registers the current instance as aGenericApplicationListener
with theApplicationEventMulticaster
which clears the listener cache. The cache will be refreshed on the next appropriateApplicationEvent
.- Parameters:
eventTypes
- The event types.- See Also:
-
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
-
onInit
protected void onInit()Description copied from class:IntegrationObjectSupport
Subclasses may implement this for initialization logic.- Overrides:
onInit
in classExpressionMessageProducerSupport
-
onApplicationEvent
- Specified by:
onApplicationEvent
in interfaceApplicationListener<ApplicationEvent>
-
supportsEventType
- Specified by:
supportsEventType
in interfaceGenericApplicationListener
-
supportsSourceType
- Specified by:
supportsSourceType
in interfaceSmartApplicationListener
-
getOrder
public int getOrder()- Specified by:
getOrder
in interfaceOrdered
- Specified by:
getOrder
in interfaceSmartApplicationListener
-
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
-