org.apache.camel.component.jmx
Class JMXConsumer

java.lang.Object
  extended by org.apache.camel.support.ServiceSupport
      extended by org.apache.camel.impl.DefaultConsumer
          extended by org.apache.camel.component.jmx.JMXConsumer
All Implemented Interfaces:
EventListener, NotificationListener, org.apache.camel.Consumer, org.apache.camel.RouteAware, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.StatefulService, org.apache.camel.SuspendableService
Direct Known Subclasses:
JMXMonitorConsumer

public class JMXConsumer
extends org.apache.camel.impl.DefaultConsumer
implements NotificationListener

Consumer will add itself as a NotificationListener on the object specified by the objectName param.


Field Summary
 
Fields inherited from class org.apache.camel.impl.DefaultConsumer
log
 
Fields inherited from class org.apache.camel.support.ServiceSupport
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending
 
Constructor Summary
JMXConsumer(JMXEndpoint endpoint, org.apache.camel.Processor processor)
           
 
Method Summary
protected  void addNotificationListener()
          Adds a notification listener to the target bean.
protected  void doStart()
          Initializes the mbean server connection and starts listening for Notification events from the object.
protected  void doStop()
          Removes the notification listeners and terminates the background connection polling process if it exists
protected  org.apache.camel.component.jmx.JMXConsumer.ConnectionNotificationListener getConnectionNotificationListener()
          Returns the connection notification listener; creates the default listener if one does not already exist
protected  NotificationXmlFormatter getFormatter()
           
protected  MBeanServerConnection getServerConnection()
           
 void handleNotification(Notification aNotification, Object aHandback)
          Processes the Notification received.
protected  void removeNotificationListeners()
          Removes the configured notification listener and the connection notification listener from the connection
protected  void scheduleDelayedStart()
          Schedules execution of the doStart() operation to occur again after the reconnect delay
protected  void scheduleReconnect()
          Schedules an attempt to re-initialize a lost connection after the reconnect delay
protected  void setServerConnection(MBeanServerConnection aServerConnection)
           
 
Methods inherited from class org.apache.camel.impl.DefaultConsumer
createUoW, doneUoW, getAsyncProcessor, getEndpoint, getExceptionHandler, getProcessor, getRoute, handleException, handleException, setExceptionHandler, setRoute, toString
 
Methods inherited from class org.apache.camel.support.ServiceSupport
doResume, doShutdown, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.camel.Service
start, stop
 

Constructor Detail

JMXConsumer

public JMXConsumer(JMXEndpoint endpoint,
                   org.apache.camel.Processor processor)
Method Detail

doStart

protected void doStart()
                throws Exception
Initializes the mbean server connection and starts listening for Notification events from the object.

Overrides:
doStart in class org.apache.camel.impl.DefaultConsumer
Throws:
Exception

getConnectionNotificationListener

protected org.apache.camel.component.jmx.JMXConsumer.ConnectionNotificationListener getConnectionNotificationListener()
Returns the connection notification listener; creates the default listener if one does not already exist


scheduleDelayedStart

protected void scheduleDelayedStart()
                             throws Exception
Schedules execution of the doStart() operation to occur again after the reconnect delay

Throws:
Exception

scheduleReconnect

protected void scheduleReconnect()
Schedules an attempt to re-initialize a lost connection after the reconnect delay


addNotificationListener

protected void addNotificationListener()
                                throws Exception
Adds a notification listener to the target bean.

Throws:
Exception

doStop

protected void doStop()
               throws Exception
Removes the notification listeners and terminates the background connection polling process if it exists

Overrides:
doStop in class org.apache.camel.impl.DefaultConsumer
Throws:
Exception

removeNotificationListeners

protected void removeNotificationListeners()
                                    throws Exception
Removes the configured notification listener and the connection notification listener from the connection

Throws:
Exception

getServerConnection

protected MBeanServerConnection getServerConnection()

setServerConnection

protected void setServerConnection(MBeanServerConnection aServerConnection)

handleNotification

public void handleNotification(Notification aNotification,
                               Object aHandback)
Processes the Notification received. The handback will be set as the header "jmx.handback" while the Notification will be set as the body.

If the format is set to "xml" then the Notification will be converted to XML first using NotificationXmlFormatter

Specified by:
handleNotification in interface NotificationListener
See Also:
NotificationListener.handleNotification(javax.management.Notification, java.lang.Object)

getFormatter

protected NotificationXmlFormatter getFormatter()


Apache Camel