Class NotificationListeningMessageProducer

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.endpoint.MessageProducerSupport
org.springframework.integration.jmx.NotificationListeningMessageProducer
All Implemented Interfaces:
EventListener, NotificationListener, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.SmartInitializingSingleton, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, org.springframework.integration.context.ExpressionCapable, org.springframework.integration.core.MessageProducer, org.springframework.integration.IntegrationPattern, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.IntegrationInboundManagement, org.springframework.integration.support.management.IntegrationManagement, org.springframework.integration.support.management.ManageableLifecycle, org.springframework.integration.support.management.ManageableSmartLifecycle, org.springframework.integration.support.management.TrackableComponent

public class NotificationListeningMessageProducer extends org.springframework.integration.endpoint.MessageProducerSupport implements NotificationListener, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
A JMX NotificationListener implementation that will send Messages containing the JMX Notification instances as their payloads.
Since:
2.0
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement

    org.springframework.integration.support.management.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.context.SmartLifecycle

    DEFAULT_PHASE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Registers the notification listener with the specified ObjectNames.
    protected void
    Unregisters the notification listener.
     
    void
    handleNotification(Notification notification, Object handback)
    Notification handling method implementation.
    void
    onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
    The NotificationListener might not be registered on AbstractEndpoint.start() because the MBeanExporter might not been started yet.
    Return a collection of ObjectName ofr provided mBeanObjectNames.
    void
    Specify a NotificationFilter to be passed to the server when registering this listener.
    void
    setHandback(Object handback)
    Specify a handback object to provide context to the listener upon notification.
    void
    setObjectName(ObjectName... objectNames)
    Specify the JMX ObjectNames (or patterns) of the notification publisher to which this notification listener should be subscribed.
    void
    Provide a reference to the MBeanServer where the notification publishing MBeans are registered.

    Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport

    afterSingletonsInstantiated, buildErrorMessage, getErrorChannel, getErrorMessageAttributes, getErrorMessageStrategy, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, onInit, 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, getIntegrationProperty, 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.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
  • Constructor Details

    • NotificationListeningMessageProducer

      public NotificationListeningMessageProducer()
  • Method Details

    • setServer

      public void setServer(MBeanServerConnection server)
      Provide a reference to the MBeanServer where the notification publishing MBeans are registered.
      Parameters:
      server - the MBean server connection.
    • setObjectName

      public void setObjectName(ObjectName... objectNames)
      Specify the JMX ObjectNames (or patterns) of the notification publisher to which this notification listener should be subscribed.
      Parameters:
      objectNames - The object names.
    • setFilter

      public void setFilter(NotificationFilter filter)
      Specify a NotificationFilter to be passed to the server when registering this listener. The filter may be null.
      Parameters:
      filter - The filter.
    • setHandback

      public void setHandback(Object handback)
      Specify a handback object to provide context to the listener upon notification. This object may be null.
      Parameters:
      handback - The object.
    • handleNotification

      public void handleNotification(Notification notification, Object handback)
      Notification handling method implementation. Creates a Message with the JMX Notification as its payload, and if the handback object is not null, it sets that as a Message header value. The Message is then sent to this producer's output channel.
      Specified by:
      handleNotification in interface NotificationListener
    • getComponentType

      public String getComponentType()
      Specified by:
      getComponentType in interface org.springframework.integration.support.context.NamedComponent
      Overrides:
      getComponentType in class org.springframework.integration.context.IntegrationObjectSupport
    • onApplicationEvent

      public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
      The NotificationListener might not be registered on AbstractEndpoint.start() because the MBeanExporter might not been started yet.
      Specified by:
      onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
      Parameters:
      event - the ContextRefreshedEvent event
    • doStart

      protected void doStart()
      Registers the notification listener with the specified ObjectNames.
      Overrides:
      doStart in class org.springframework.integration.endpoint.MessageProducerSupport
    • doStop

      protected void doStop()
      Unregisters the notification listener.
      Overrides:
      doStop in class org.springframework.integration.endpoint.MessageProducerSupport
    • retrieveMBeanNames

      protected Collection<ObjectName> retrieveMBeanNames()
      Return a collection of ObjectName ofr provided mBeanObjectNames.
      Returns:
      the collection of ObjectName ofr provided mBeanObjectNames.