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:
java.util.EventListener
,javax.management.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 javax.management.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, lifecycleLock
-
Constructor Summary
Constructors Constructor Description NotificationListeningMessageProducer()
-
Method Summary
Modifier and Type Method Description protected void
doStart()
Registers the notification listener with the specified ObjectNames.protected void
doStop()
Unregisters the notification listener.java.lang.String
getComponentType()
void
handleNotification(javax.management.Notification notification, java.lang.Object handback)
Notification handling method implementation.void
onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
TheNotificationListener
might not be registered onAbstractEndpoint.start()
because theMBeanExporter
might not been started yet.protected java.util.Collection<javax.management.ObjectName>
retrieveMBeanNames()
void
setFilter(javax.management.NotificationFilter filter)
Specify aNotificationFilter
to be passed to the server when registering this listener.void
setHandback(java.lang.Object handback)
Specify a handback object to provide context to the listener upon notification.void
setObjectName(javax.management.ObjectName... objectNames)
Specify the JMX ObjectNames (or patterns) of the notification publisher to which this notification listener should be subscribed.void
setServer(javax.management.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, getIntegrationPatternType, getMessagingTemplate, getOutputChannel, onInit, sendErrorMessageIfNecessary, sendMessage, setErrorChannel, setErrorChannelName, setErrorMessageStrategy, 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
-
Constructor Details
-
NotificationListeningMessageProducer
public NotificationListeningMessageProducer()
-
-
Method Details
-
setServer
public void setServer(javax.management.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(javax.management.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(javax.management.NotificationFilter filter)Specify aNotificationFilter
to be passed to the server when registering this listener. The filter may be null.- Parameters:
filter
- The filter.
-
setHandback
public void setHandback(java.lang.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(javax.management.Notification notification, java.lang.Object handback)Notification handling method implementation. Creates a Message with the JMXNotification
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 interfacejavax.management.NotificationListener
-
getComponentType
public java.lang.String getComponentType()- Specified by:
getComponentType
in interfaceorg.springframework.integration.support.context.NamedComponent
- Overrides:
getComponentType
in classorg.springframework.integration.context.IntegrationObjectSupport
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)TheNotificationListener
might not be registered onAbstractEndpoint.start()
because theMBeanExporter
might not been started yet.- Specified by:
onApplicationEvent
in 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:
doStart
in classorg.springframework.integration.endpoint.MessageProducerSupport
-
doStop
protected void doStop()Unregisters the notification listener.- Overrides:
doStop
in classorg.springframework.integration.endpoint.MessageProducerSupport
-
retrieveMBeanNames
protected java.util.Collection<javax.management.ObjectName> retrieveMBeanNames()
-