|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.sun.jini.example.basic.ex1.activation.AbstractDeactivator
com.sun.jini.example.basic.ex1.activation.ServiceDeactivator
Class which implements the criteria for deactivating an activatable object as defined by the abstract class AbstractDeactivator. An activatable object that wishes to be deactivated should instantiate this class in its constructor. This class determines whether or not an active object should be deactivated based on a measure of "busy-ness"; which any class that extends the AbstractDeactivator class must define. Because deactivation and reactivation are 'expensive' processes, this class will NOT deactivate an object if at least N remote methods of the object have been invoked, and un-processed, in the past T milliseconds; where the values of N and T are supplied by the activatable object that wishes to be deactivated.
| Constructor Summary | |
ServiceDeactivator(java.rmi.activation.ActivationID activationID)
Constructor invoked by an activatable object which supplies neither a wait interval nor a 'busy-ness' threshold; allowing both to revert to their default values. |
|
ServiceDeactivator(java.rmi.activation.ActivationID activationID,
int threshold)
Constructor invoked by an activatable object which supplies only its own 'busy-ness' threshold; but lets the wait interval revert to the default value. |
|
ServiceDeactivator(java.rmi.activation.ActivationID activationID,
long waitMS)
Constructor invoked by an activatable object which supplies only its own wait interval; but lets the 'busy-ness' threshold revert to the default value. |
|
ServiceDeactivator(java.rmi.activation.ActivationID activationID,
long waitMS,
int threshold)
Constructor invoked by an activatable object which supplies its own wait interval and 'busy-ness' threshold. |
|
| Method Summary | |
protected boolean |
deactivateObject(java.rmi.activation.ActivationID activationID)
This method will attempt to change the state of the object from active to inactive. |
protected void |
decreaseBusyMetric()
This method 'decrements' the measure of how 'busy' an activatable object is. |
protected void |
handleException(java.lang.Exception e)
This method handles any Exception in a manner that is appropriate for the operational environment of the object that wishes to be deactivated. |
void |
increaseBusyMetric()
This method 'increments' the measure of how 'busy' an activatable object is. |
protected boolean |
objectIsBusy()
This method measures how 'busy' the activatable object is and returns true if it is too busy to be deactivated; otherwise it returns false indicating deactivation may be safely attempted. |
protected boolean |
objectIsIdle()
This method returns an indication of whether or not the object that wishes to be deactivated has entered a state in which it is appropriate to begin deactivation attempts. |
protected void |
waitBeforeDeactivation()
This method will wait an amount of time before returning. |
protected void |
wakeDeactivatorThread()
This method will wake this class' DeactivatorThread from its wait state. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ServiceDeactivator(java.rmi.activation.ActivationID activationID,
long waitMS,
int threshold)
activationID - ActivationID of the activatable objectwaitMS - milliseconds to wait before retrying deactivationthreshold - deactivation will NOT be attempted if at least
this many remote methods have been invoked, and
un-processed, in the past waitMS milliseconds.
public ServiceDeactivator(java.rmi.activation.ActivationID activationID,
long waitMS)
activationID - ActivationID of the activatable objectwaitMS - milliseconds to wait before retrying deactivation
public ServiceDeactivator(java.rmi.activation.ActivationID activationID,
int threshold)
activationID - ActivationID of the activatable objectpublic ServiceDeactivator(java.rmi.activation.ActivationID activationID)
activationID - ActivationID of the activatable object| Method Detail |
public void increaseBusyMetric()
AbstractDeactivatorAlthough the definition of the measure of an object's 'busy-ness', as well as the method by which that measure is updated, are left to be defined by the concrete implementation of this method, invoking this method should always result in an increase in that measure in some manner that is meaningful for the activatable object.
Requirement: for any activatable object that employs this class to become inactive, every remote method of that object must invoke this method so as to increase the measure of how 'busy' the object is.
increaseBusyMetric in class AbstractDeactivatorAbstractDeactivator.increaseBusyMetric()protected void decreaseBusyMetric()
AbstractDeactivatorAlthough the definition of the measure of an object's 'busy-ness', as well as the method by which that measure is updated, are left for the concrete implementation of this method, invoking this method should always result in a decrease in that measure in some manner that is meaningful for the activatable object.
This method is only invoked by the DeactivatorThread inner class defined in this class.
decreaseBusyMetric in class AbstractDeactivatorAbstractDeactivator.decreaseBusyMetric()protected boolean objectIsIdle()
AbstractDeactivatorThis method is used to avoid attempting deactivation before the Activation System has had a chance to complete its activation of the object. Deactivation cannot safely occur if a previously inactive object is in the process of being activated.
objectIsIdle in class AbstractDeactivatorAbstractDeactivator.objectIsIdle()protected boolean objectIsBusy()
AbstractDeactivatorThis method is used to determine when to attempt deactivation. The concrete implementation must define a measure of busy-ness as well as a criteria for deactivation that is appropriate for the needs of the object wishing to be deactivated.
objectIsBusy in class AbstractDeactivatorAbstractDeactivator.objectIsBusy()protected void handleException(java.lang.Exception e)
AbstractDeactivatorThis abstract method allows the concrete implementation of this class to define how an Exception should be handled. Since some objects will have access to a display screen, and some will not, it is important that this class make no assumptions about the mechanism an object will use to deal with such exceptions. Some implementations may decide to log the exception to a screen or to a file, some may ignore the exception, still others may handle the exception in manner that is unique to the application.
handleException in class AbstractDeactivatorAbstractDeactivator.handleException(java.lang.Exception)protected void waitBeforeDeactivation()
AbstractDeactivatorIf it is desirable to change the delay mechanism employed by this class, or to perform any processing in addition to the delay, then this method should be overridden by the concrete implementation of this class.
waitBeforeDeactivation in class AbstractDeactivatorAbstractDeactivator.waitBeforeDeactivation()protected void wakeDeactivatorThread()
AbstractDeactivatorRequirement: for every concrete implementation of this class, the implementation of the method increaseBusyMetric is required to invoke this method after the busy metric has been increased.
Requirement: if the concrete implementation of this class overrides this method, the overriding implementation is required to invoke super.wakeDeactivatorThread after any preprocessing is performed.
wakeDeactivatorThread in class AbstractDeactivatorAbstractDeactivator.wakeDeactivatorThread()
protected boolean deactivateObject(java.rmi.activation.ActivationID activationID)
throws java.rmi.RemoteException,
java.rmi.activation.ActivationException,
java.rmi.activation.UnknownObjectException
AbstractDeactivatorRequirement: if the concrete implementation of this class overrides this method, the overriding implementation is required to invoke super.deactivateObject after any preprocessing is performed.
deactivateObject in class AbstractDeactivatoractivationID - id needed to deactivate the activatable object
java.rmi.RemoteException
java.rmi.activation.ActivationException
java.rmi.activation.UnknownObjectExceptionAbstractDeactivator.deactivateObject(java.rmi.activation.ActivationID)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||