com.sun.jini.example.basic.ex1.activation
Class AbstractDeactivator

java.lang.Object
  extended bycom.sun.jini.example.basic.ex1.activation.AbstractDeactivator
Direct Known Subclasses:
ServiceDeactivator

public abstract class AbstractDeactivator
extends java.lang.Object

An abstract class which provides the framework for the behavior required of a concrete object that wishes to enable an activatable object to become inactive. When the required concrete extension to this class is implemented, that implementation must provide a definition of the criteria for deactivating the activatable object.

An activatable object that desires the ability to become inactive must instantiate this class' concrete sub-class in its constructor.


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 abstract  void decreaseBusyMetric()
          This method 'decrements' the measure of how 'busy' an activatable object is.
protected abstract  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.
abstract  void increaseBusyMetric()
          This method 'increments' the measure of how 'busy' an activatable object is.
protected abstract  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 abstract  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
 

Method Detail

increaseBusyMetric

public abstract void increaseBusyMetric()
This method 'increments' the measure of how 'busy' an activatable object is.

Although 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.


decreaseBusyMetric

protected abstract void decreaseBusyMetric()
This method 'decrements' the measure of how 'busy' an activatable object is.

Although 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.


objectIsIdle

protected abstract 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. For the purposes of deactivation, this method defines an object to be in an idle state if the busy measure of the object is zero.

This 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.

Returns:
boolean if the object that wishes to be deactivated has a busy measure of zero, return true; otherwise return false.

objectIsBusy

protected abstract 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.

This 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.

Returns:
boolean if the object that wishes to be deactivated has a busy measure that satisfies deactivation criteria, return true; otherwise return false.

handleException

protected abstract 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.

This 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.


waitBeforeDeactivation

protected void waitBeforeDeactivation()
This method will wait an amount of time before returning. This is used to insert a time delay between deactivation attempts.

If 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.


wakeDeactivatorThread

protected void wakeDeactivatorThread()
This method will wake this class' DeactivatorThread from its wait state. When that thread awakes, it will either attempt to deactivate the object, or it will decrement the busy measure of the object. If it is desirable to perform any processing prior to waking the DeactivatorThread, then this method should be overridden by the concrete implementation of this class.

Requirement: 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.


deactivateObject

protected boolean deactivateObject(java.rmi.activation.ActivationID activationID)
                            throws java.rmi.RemoteException,
                                   java.rmi.activation.ActivationException,
                                   java.rmi.activation.UnknownObjectException
This method will attempt to change the state of the object from active to inactive. If it is desirable to perform any preprocessing prior to attempting the deactivation of the object, then this method should be overridden by the concrete implementation of this class.

Requirement: if the concrete implementation of this class overrides this method, the overriding implementation is required to invoke super.deactivateObject after any preprocessing is performed.

Parameters:
activationID - id needed to deactivate the activatable object
Throws:
java.rmi.RemoteException
java.rmi.activation.ActivationException
java.rmi.activation.UnknownObjectException


Copyright © 2003 Sun Microsystems Corp. All Rights Reserved.