Spring Integration

org.springframework.integration.event.inbound
Class ApplicationEventListeningMessageProducer

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.endpoint.AbstractEndpoint
          extended by org.springframework.integration.endpoint.MessageProducerSupport
              extended by org.springframework.integration.endpoint.ExpressionMessageProducerSupport
                  extended by org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer
All Implemented Interfaces:
java.util.EventListener, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>, org.springframework.context.event.SmartApplicationListener, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, org.springframework.core.Ordered, NamedComponent, MessageProducer, TrackableComponent

public class ApplicationEventListeningMessageProducer
extends ExpressionMessageProducerSupport
implements org.springframework.context.event.SmartApplicationListener

An inbound Channel Adapter that implements ApplicationListener 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
See Also:
ApplicationEventMulticaster, ExpressionMessageProducerSupport

Field Summary
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
ApplicationEventListeningMessageProducer()
           
 
Method Summary
protected  void doStart()
          Takes no action by default.
protected  void doStop()
          Takes no action by default.
 java.lang.String getComponentType()
          Subclasses may implement this method to provide component type information.
 int getOrder()
           
 void onApplicationEvent(org.springframework.context.ApplicationEvent event)
           
protected  void onInit()
          Subclasses may implement this for initialization logic.
 void setEventTypes(java.lang.Class<? extends org.springframework.context.ApplicationEvent>... eventTypes)
          Set the list of event types (classes that extend ApplicationEvent) that this adapter should send to the message channel.
 boolean supportsEventType(java.lang.Class<? extends org.springframework.context.ApplicationEvent> eventType)
           
 boolean supportsSourceType(java.lang.Class<?> sourceType)
           
 
Methods inherited from class org.springframework.integration.endpoint.ExpressionMessageProducerSupport
evaluatePayloadExpression, setPayloadExpression
 
Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport
sendMessage, setErrorChannel, setOutputChannel, setSendTimeout, setShouldTrack
 
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
getPhase, isAutoStartup, isRunning, setAutoStartup, setPhase, setTaskScheduler, start, stop, stop
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getApplicationContextId, getBeanFactory, getComponentName, getConversionService, getTaskScheduler, setApplicationContext, setBeanFactory, setBeanName, setComponentName, setConversionService, 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.context.NamedComponent
getComponentName
 

Constructor Detail

ApplicationEventListeningMessageProducer

public ApplicationEventListeningMessageProducer()
Method Detail

setEventTypes

public void setEventTypes(java.lang.Class<? extends org.springframework.context.ApplicationEvent>... eventTypes)
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 a ApplicationListener with the ApplicationEventMulticaster which clears the listener cache. The cache will be refreshed on the next appropriate ApplicationEvent.

See Also:
ApplicationEventMulticaster.addApplicationListener(org.springframework.context.ApplicationListener), supportsEventType(java.lang.Class)

getComponentType

public java.lang.String getComponentType()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this method to provide component type information.

Specified by:
getComponentType in interface NamedComponent
Overrides:
getComponentType in class IntegrationObjectSupport

onInit

protected void onInit()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this for initialization logic.

Overrides:
onInit in class MessageProducerSupport

onApplicationEvent

public void onApplicationEvent(org.springframework.context.ApplicationEvent event)
Specified by:
onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>

supportsEventType

public boolean supportsEventType(java.lang.Class<? extends org.springframework.context.ApplicationEvent> eventType)
Specified by:
supportsEventType in interface org.springframework.context.event.SmartApplicationListener

supportsSourceType

public boolean supportsSourceType(java.lang.Class<?> sourceType)
Specified by:
supportsSourceType in interface org.springframework.context.event.SmartApplicationListener

getOrder

public int getOrder()
Specified by:
getOrder in interface org.springframework.core.Ordered

doStart

protected void doStart()
Description copied from class: MessageProducerSupport
Takes no action by default. Subclasses may override this if they need lifecycle-managed behavior.

Overrides:
doStart in class MessageProducerSupport

doStop

protected void doStop()
Description copied from class: MessageProducerSupport
Takes no action by default. Subclasses may override this if they need lifecycle-managed behavior.

Overrides:
doStop in class MessageProducerSupport

Spring Integration