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.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
-
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.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoStart()Registers the notification listener with the specified ObjectNames.protected voiddoStop()Unregisters the notification listener.voidhandleNotification(Notification notification, Object handback) Notification handling method implementation.voidonApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) TheNotificationListenermight not be registered onAbstractEndpoint.start()because theMBeanExportermight not been started yet.protected Collection<ObjectName>Return a collection ofObjectNameofr providedmBeanObjectNames.voidsetFilter(NotificationFilter filter) Specify aNotificationFilterto be passed to the server when registering this listener.voidsetHandback(Object handback) Specify a handback object to provide context to the listener upon notification.voidsetObjectName(ObjectName... objectNames) Specify the JMX ObjectNames (or patterns) of the notification publisher to which this notification listener should be subscribed.voidsetServer(MBeanServerConnection server) 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, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, setOutputChannel, setOutputChannelName, setSendTimeout, setShouldTrack, subscribeToPublisherMethods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
destroy, doStop, getPhase, getRole, isActive, 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.context.NamedComponent
getBeanName, getComponentName
-
Constructor Details
-
NotificationListeningMessageProducer
public NotificationListeningMessageProducer()
-
-
Method Details
-
setServer
Provide a reference to the MBeanServer where the notification publishing MBeans are registered.- Parameters:
server- the MBean server connection.
-
setObjectName
Specify the JMX ObjectNames (or patterns) of the notification publisher to which this notification listener should be subscribed.- Parameters:
objectNames- The object names.
-
setFilter
Specify aNotificationFilterto be passed to the server when registering this listener. The filter may be null.- Parameters:
filter- The filter.
-
setHandback
Specify a handback object to provide context to the listener upon notification. This object may be null.- Parameters:
handback- The object.
-
handleNotification
Notification handling method implementation. Creates a Message with the JMXNotificationas 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:
handleNotificationin interfaceNotificationListener
-
getComponentType
- Specified by:
getComponentTypein interfaceorg.springframework.integration.support.context.NamedComponent- Overrides:
getComponentTypein classorg.springframework.integration.context.IntegrationObjectSupport
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) TheNotificationListenermight not be registered onAbstractEndpoint.start()because theMBeanExportermight not been started yet.- Specified by:
onApplicationEventin interfaceorg.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:
doStartin classorg.springframework.integration.endpoint.MessageProducerSupport
-
doStop
protected void doStop()Unregisters the notification listener.- Overrides:
doStopin classorg.springframework.integration.endpoint.MessageProducerSupport
-
retrieveMBeanNames
Return a collection ofObjectNameofr providedmBeanObjectNames.- Returns:
- the collection of
ObjectNameofr providedmBeanObjectNames.
-