org.jboss.mx.remoting.tracker
Class MBeanTracker

java.lang.Object
  extended by org.jboss.mx.remoting.tracker.MBeanTracker
All Implemented Interfaces:
EventListener, NotificationListener

public class MBeanTracker
extends Object
implements NotificationListener

MBeanTracker is a utility class that will track MBeans on behalf of a user object.

Version:
$Revision: 81023 $
Author:
Jeff Haynie

Constructor Summary
MBeanTracker(MBeanServer myserver, Class[] cl, boolean localOnly, MBeanTrackerAction action)
           
MBeanTracker(MBeanServer myserver, Class[] cl, boolean localOnly, MBeanTrackerAction[] actions)
           
MBeanTracker(MBeanServer myserver, Class[] cl, QueryExp query, boolean localOnly, MBeanTrackerAction action)
           
MBeanTracker(MBeanServer myserver, Class[] cl, QueryExp query, boolean localOnly, MBeanTrackerAction[] actions)
           
MBeanTracker(MBeanServer myserver, Class[] cl, QueryExp query, boolean localOnly, NotificationFilter filter, boolean wantNotifications)
           
MBeanTracker(MBeanServer myserver, Class[] cl, QueryExp query, boolean localOnly, NotificationFilter filter, boolean wantNotifications, MBeanTrackerAction action)
           
MBeanTracker(MBeanServer myserver, Class[] cl, QueryExp query, boolean localOnly, NotificationFilter filter, boolean wantNotifications, MBeanTrackerAction[] actions)
          create a tracker
 
Method Summary
 void addActionListener(MBeanTrackerAction action)
          add a action listener.
 void addActionListener(MBeanTrackerAction action, boolean autoinitialregister)
          add a action listener.
 int count()
          return the number of mbeans being tracked
 void destroy()
          called to stop tracking and clean up internally held resources
protected  void finalize()
           
protected  void fireNotification(MBeanLocator locator, Notification n, Object o)
          fire a notification to actions
protected  void fireRegister(MBeanLocator locator)
          fire register event to listeners
protected  void fireStateChange(MBeanLocator locator, int ov, int nv)
          fire a state changed event to actions
protected  void fireUnregister(MBeanLocator locator)
          fire unregister event to listeners
 void foundMBeanServer(MBeanServerLocator theserver)
          fired when an MBeanServer is found
 Set getMBeans()
          return a copy of the internal mbeans being tracked
 void handleNotification(Notification notification, Object o)
          called for each notification
 boolean isEmpty()
          returns true if no mbeans are found that are being tracked
 Iterator iterator()
          return an iterator to a copy of the internal mbeans being tracked
 void lostMBeanServer(MBeanServerLocator server)
          fired when we lose an MBeanServer
 void removeActionListener(MBeanTrackerAction action)
          remove a action listener
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MBeanTracker

public MBeanTracker(MBeanServer myserver,
                    Class[] cl,
                    QueryExp query,
                    boolean localOnly,
                    MBeanTrackerAction action)
             throws Exception
Throws:
Exception

MBeanTracker

public MBeanTracker(MBeanServer myserver,
                    Class[] cl,
                    QueryExp query,
                    boolean localOnly,
                    MBeanTrackerAction[] actions)
             throws Exception
Throws:
Exception

MBeanTracker

public MBeanTracker(MBeanServer myserver,
                    Class[] cl,
                    boolean localOnly,
                    MBeanTrackerAction action)
             throws Exception
Throws:
Exception

MBeanTracker

public MBeanTracker(MBeanServer myserver,
                    Class[] cl,
                    boolean localOnly,
                    MBeanTrackerAction[] actions)
             throws Exception
Throws:
Exception

MBeanTracker

public MBeanTracker(MBeanServer myserver,
                    Class[] cl,
                    QueryExp query,
                    boolean localOnly,
                    NotificationFilter filter,
                    boolean wantNotifications,
                    MBeanTrackerAction action)
             throws Exception
Throws:
Exception

MBeanTracker

public MBeanTracker(MBeanServer myserver,
                    Class[] cl,
                    QueryExp query,
                    boolean localOnly,
                    NotificationFilter filter,
                    boolean wantNotifications)
             throws Exception
Throws:
Exception

MBeanTracker

public MBeanTracker(MBeanServer myserver,
                    Class[] cl,
                    QueryExp query,
                    boolean localOnly,
                    NotificationFilter filter,
                    boolean wantNotifications,
                    MBeanTrackerAction[] actions)
             throws Exception
create a tracker

Parameters:
myserver - local mbean server
cl - array of classes that mbeans implement that you want to track, or null to not look at class interfaces
query - query expression to apply when selecting mbeans or null to not use a query expression
localOnly - true to only search the local mbeanserver, false to search the entire network of mbeans servers
filter - filter to apply for receiving notifications or null to apply no filter
wantNotifications - if true, will also track notifications by the mbeans being tracked
actions - array of actions to automatically register as listeners, or null if none
Throws:
Exception - raised on exception
Method Detail

addActionListener

public void addActionListener(MBeanTrackerAction action)
add a action listener. this method will automatically call register to your action on all the mbeans that are contained within it before this method returns.

Parameters:
action -

addActionListener

public void addActionListener(MBeanTrackerAction action,
                              boolean autoinitialregister)
add a action listener. this method will automatically call register to your action on all the mbeans that are contained within it before this method returns.

Parameters:
action -

removeActionListener

public void removeActionListener(MBeanTrackerAction action)
remove a action listener

Parameters:
action -

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

destroy

public void destroy()
called to stop tracking and clean up internally held resources


isEmpty

public final boolean isEmpty()
returns true if no mbeans are found that are being tracked

Returns:

count

public final int count()
return the number of mbeans being tracked

Returns:

getMBeans

public final Set getMBeans()
return a copy of the internal mbeans being tracked

Returns:

iterator

public final Iterator iterator()
return an iterator to a copy of the internal mbeans being tracked

Returns:

handleNotification

public void handleNotification(Notification notification,
                               Object o)
called for each notification

Specified by:
handleNotification in interface NotificationListener
Parameters:
notification -
o -

fireNotification

protected void fireNotification(MBeanLocator locator,
                                Notification n,
                                Object o)
fire a notification to actions

Parameters:
locator -
n -
o -

fireStateChange

protected void fireStateChange(MBeanLocator locator,
                               int ov,
                               int nv)
fire a state changed event to actions

Parameters:
locator -
ov -
nv -

fireUnregister

protected void fireUnregister(MBeanLocator locator)
fire unregister event to listeners

Parameters:
locator -

fireRegister

protected void fireRegister(MBeanLocator locator)
fire register event to listeners

Parameters:
locator -

foundMBeanServer

public void foundMBeanServer(MBeanServerLocator theserver)
fired when an MBeanServer is found

Parameters:
theserver -

lostMBeanServer

public void lostMBeanServer(MBeanServerLocator server)
fired when we lose an MBeanServer

Parameters:
server -


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.