|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.sadun.util.watchdog.mbean.ManagedWatchDog
NON COMPLETE YET.
An implementation of ManagedWatchDogMBean.
Unlike WatchDog, this implementation is
concrete and can be directly instantiated. The specific check action to
perform can be specified by declaring the
ManagedWatchDogMBean.CheckActionclass name via the
setCheckActionClassName(String)method (or the equivalent CheckActionClassName
JMX attribute).
However, it is still possible to extend the class and construct a subclass which
WatchDogclass
(typically, an already existing watchdog)
WatchDog.CheckActionobject which specifies the
checking semantics.
Therfore, to create a JMX-instrumented watchdog, a developer can:
WatchDogand overriding
WatchDog.doCheck(Object))
ManagedWatchDogMBean.CheckAction. For example,
class MyCheck implements ManagedWatchDogMBean.CheckAction { public Throwable doCheck(Object obj) throws WatchDogException { System.out.println("Fake check"); return null; } }
class MyManagedWatchDog extends ManagedWatchDog { public MyManagedWatchDog() { super("MyManagedWatchDog", new MyCheck()); } }
<mbean code="org.sadun.util.watchdog.mbean.ManagedWatchDog"> <attribute name="CheckActionClassName">MyCheck<attribute> <mbean>
| Nested Class Summary |
| Nested classes inherited from class org.sadun.util.watchdog.mbean.ManagedWatchDogMBean |
ManagedWatchDogMBean.CheckAction |
| Field Summary | |
protected javax.management.ObjectName |
mbeanName
The objectname with which this watchdog is registered. |
protected WatchDog |
watchDog
The embedded watchdog object. |
| Constructor Summary | |
ManagedWatchDog()
Constructor which leaves all definitions to subsequent set calls. |
|
ManagedWatchDog(java.lang.String name,
long checkPeriodTime,
boolean synchronous,
ManagedWatchDogMBean.CheckAction action)
Create a WatchDog MBean with the given check period, in milliseconds, and the given associated action. |
|
ManagedWatchDog(java.lang.String name,
long checkPeriodTime,
ManagedWatchDogMBean.CheckAction action)
Create a WatchDog MBean which wraps an existing concrete WatchDogclass. |
|
ManagedWatchDog(java.lang.String name,
ManagedWatchDogMBean.CheckAction action)
Create a WatchDog MBean with the default check period time. |
|
| Method Summary | |
void |
addListener(WatchDog.Listener l)
Add a watchdog listener to the listener set. |
java.lang.String |
getCheckActionClassName()
Get the name of the check action class in use. |
java.lang.Object |
getCheckActionParameter(java.lang.String name)
Return the value of a parameter in the current check action object. |
long |
getCheckPeriodTime()
Return the amount of time the watchdog waits between each check. |
java.lang.String |
getName()
Set the name of the watchdog tGread |
boolean |
isAlive()
Return true if the watchdog thread is currently running. |
boolean |
isShuttingDown()
Return true if a shutdown has been requested. |
boolean |
isStartBySleeping()
Return true if the watchdog goes immediatly to sleep on startup |
boolean |
isSynchronous()
Return the synchronicity mode (see class comment). |
void |
postDeregister()
|
void |
postRegister(java.lang.Boolean registrationDone)
|
void |
preDeregister()
|
javax.management.ObjectName |
preRegister(javax.management.MBeanServer server,
javax.management.ObjectName name)
|
void |
removeListener(WatchDog.Listener l)
Remove a watchdog listener from the listeners set. |
void |
setCheckActionClassName(java.lang.String name)
Set the name of the check action class to use.
|
void |
setCheckActionParameter(java.lang.String name,
java.lang.Object value)
Set a parameter on the current check action object. |
void |
setCheckPeriodTime(long checkPeriodTime)
Set the amount of time the watchdog waits between each check. |
void |
setName(java.lang.String name)
Set the name of the watchdog thread |
void |
setStartBySleeping(boolean startBySleeping)
|
void |
shutdown()
Unconditionally requests a shutdown. |
void |
startup()
Start the watchdog thread. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected WatchDog watchDog
protected javax.management.ObjectName mbeanName
| Constructor Detail |
public ManagedWatchDog(java.lang.String name,
long checkPeriodTime,
ManagedWatchDogMBean.CheckAction action)
WatchDogclass.
name - the name of the WatchDog threadcheckPeriodTime - the amount of time the watchdog waits between each check.action - the CheckActionto perform
public ManagedWatchDog(java.lang.String name,
long checkPeriodTime,
boolean synchronous,
ManagedWatchDogMBean.CheckAction action)
The watchdog can be created in either synchronous or asynchronous mode.
In the former case, listeners are invoked in the WatchDog thread - and if they block, the WatchDog thread will block; in the latter case, listeners execution is decoupled from the WatchDog thread.
Asynchronous mode requires is heavier and requires more resources.
name - the name of the WatchDog threadcheckPeriodTime - the amount of time the watchdog waits between each check.synchronous - if true, synchronous mode is selected, else
asynchronous.action - the CheckActionto perform
public ManagedWatchDog(java.lang.String name,
ManagedWatchDogMBean.CheckAction action)
name - the name of the WatchDog thread asynchronous.action - the CheckActionto performpublic ManagedWatchDog()
| Method Detail |
public void postDeregister()
postDeregister in interface javax.management.MBeanRegistrationpublic void postRegister(java.lang.Boolean registrationDone)
postRegister in interface javax.management.MBeanRegistration
public void preDeregister()
throws java.lang.Exception
preDeregister in interface javax.management.MBeanRegistrationjava.lang.Exception
public javax.management.ObjectName preRegister(javax.management.MBeanServer server,
javax.management.ObjectName name)
throws java.lang.Exception
preRegister in interface javax.management.MBeanRegistrationjava.lang.Exceptionpublic void addListener(WatchDog.Listener l)
ManagedWatchDogMBean
addListener in interface ManagedWatchDogMBeanl - the listener to addpublic long getCheckPeriodTime()
ManagedWatchDogMBean
getCheckPeriodTime in interface ManagedWatchDogMBeanpublic java.lang.String getName()
ManagedWatchDogMBean
getName in interface ManagedWatchDogMBeanpublic boolean isAlive()
ManagedWatchDogMBean
isAlive in interface ManagedWatchDogMBeanpublic boolean isShuttingDown()
ManagedWatchDogMBean
isShuttingDown in interface ManagedWatchDogMBeanpublic boolean isStartBySleeping()
ManagedWatchDogMBean
isStartBySleeping in interface ManagedWatchDogMBeanpublic boolean isSynchronous()
ManagedWatchDogMBean
isSynchronous in interface ManagedWatchDogMBeanpublic void removeListener(WatchDog.Listener l)
ManagedWatchDogMBean
removeListener in interface ManagedWatchDogMBeanl - the listener to removepublic void setCheckPeriodTime(long checkPeriodTime)
ManagedWatchDogMBean
setCheckPeriodTime in interface ManagedWatchDogMBeancheckPeriodTime - the amount of time the watchdog waits between each check.public void setName(java.lang.String name)
ManagedWatchDogMBean
setName in interface ManagedWatchDogMBeanname - the name of the watchdog threadpublic void setStartBySleeping(boolean startBySleeping)
setStartBySleeping in interface ManagedWatchDogMBeanstartBySleeping - The startBySleeping to set.public void shutdown()
ManagedWatchDogMBean
shutdown in interface ManagedWatchDogMBeanpublic void startup()
ManagedWatchDogMBean
startup in interface ManagedWatchDogMBeanpublic java.lang.String getCheckActionClassName()
ManagedWatchDogMBeancheck action class in use.
getCheckActionClassName in interface ManagedWatchDogMBeancheck action class in use.
public void setCheckActionClassName(java.lang.String name)
throws javax.management.MBeanException
ManagedWatchDogMBeancheck action class to use.
The class must have a public default constructor.
This method attempts to create an instance of the class, and a corresponding WatchDog object. An MBeanException is raised in case of problem doing so.
This method can be called only once.
setCheckActionClassName in interface ManagedWatchDogMBeanname - the name of the check action class to use.
javax.management.MBeanException
public java.lang.Object getCheckActionParameter(java.lang.String name)
throws javax.management.MBeanException
ManagedWatchDogMBeanCheckActionClassName
attribute must be set to a valid, constructable class before this method is invoked.
getCheckActionParameter in interface ManagedWatchDogMBeanname - the name of the check action parameter.
javax.management.MBeanException
public void setCheckActionParameter(java.lang.String name,
java.lang.Object value)
throws javax.management.MBeanException
ManagedWatchDogMBeanCheckActionClassName
attribute must be set to a valid, constructable class before this method is invoked.
setCheckActionParameter in interface ManagedWatchDogMBeanname - the name of the check action parameter.value - the value to set
javax.management.MBeanException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||