org.oddjob.framework
Class BaseComponent

java.lang.Object
  extended byorg.oddjob.framework.BaseComponent
All Implemented Interfaces:
Iconic
Direct Known Subclasses:
BasePrimary, BaseWrapper, JMXClientJob

public abstract class BaseComponent
extends java.lang.Object
implements Iconic

An abstract implementation of a component which provides commen functionality to concrete sub classes.

Author:
Rob Gordon

Field Summary
protected  java.beans.PropertyChangeSupport changes
          Implement property change support which sub classes can take advantage of.
protected  boolean destroyed
          This flag is set once the object is destroyed Methods in subclass should check this flag.
protected  IconHelper iconHelper
          Used to notify clients of an icon change.
protected  Location location
          The location.
protected  Lock lock
          This locks the component.
protected  JobStateHandler stateHandler
          A state handler to delagate state change functionality to.
 
Constructor Summary
BaseComponent()
           
 
Method Summary
 void addIconListener(IconListener listener)
          Add an icon listener.
 void addJobStateListener(JobStateListener listener)
          Add a job state listener.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a property change listener.
protected  RuntimeConfiguration arooaRuntime()
           
 void arooaRuntime(ArooaRuntime arooaRuntime)
           
protected  boolean canHardReset()
           
protected  boolean canSoftReset()
           
protected  boolean configure()
          Configure the runtime.
 void destroy()
          Destroy resources.
 Location getLocation()
           
 IconTip iconForId(java.lang.String iconId)
          Return an icon tip for a given id.
 JobStateEvent lastJobStateEvent()
          Returns the last JobState event.
protected abstract  org.apache.log4j.Logger logger()
           
 void onDestroy()
          Subclasses override this method to clear up resources.
 void removeIconListener(IconListener listener)
          Remove an icon listener.
 void removeJobStateListener(JobStateListener listener)
          Remove a job state listener.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a property change listener.
protected  void setJobStateComplete()
           
protected  void setJobStateException(java.lang.Throwable ex)
          Utility method to set the job state to exception.
protected  void setJobStateNotComplete()
           
protected  void setJobStateReady()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

location

protected Location location
The location.


changes

protected java.beans.PropertyChangeSupport changes
Implement property change support which sub classes can take advantage of.


iconHelper

protected IconHelper iconHelper
Used to notify clients of an icon change.


stateHandler

protected JobStateHandler stateHandler
A state handler to delagate state change functionality to.


destroyed

protected volatile boolean destroyed
This flag is set once the object is destroyed Methods in subclass should check this flag.


lock

protected Lock lock
This locks the component. It can be used by methods in subclasses to ensure the component is locked before proceeding.

Constructor Detail

BaseComponent

public BaseComponent()
Method Detail

logger

protected abstract org.apache.log4j.Logger logger()

arooaRuntime

public void arooaRuntime(ArooaRuntime arooaRuntime)

getLocation

public Location getLocation()

arooaRuntime

protected RuntimeConfiguration arooaRuntime()

setJobStateReady

protected void setJobStateReady()

setJobStateComplete

protected void setJobStateComplete()

setJobStateNotComplete

protected void setJobStateNotComplete()

setJobStateException

protected void setJobStateException(java.lang.Throwable ex)
Utility method to set the job state to exception.

Parameters:
ex - The exception.

configure

protected boolean configure()
Configure the runtime. If there is no runtime for this component then true is returned.

Returns:
true if sucessful. False if not.

canSoftReset

protected boolean canSoftReset()

canHardReset

protected boolean canHardReset()

lastJobStateEvent

public JobStateEvent lastJobStateEvent()
Returns the last JobState event. This is useful when Jobs are being used directly in code, and only one thread is using the job. Otherwise a JobStateListener should always be used.

This is not a property so that it can't be accessed directly in scripts.

Returns:
The last JobStateEvent. Will never be null.

addJobStateListener

public void addJobStateListener(JobStateListener listener)
Add a job state listener.


removeJobStateListener

public void removeJobStateListener(JobStateListener listener)
Remove a job state listener.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a property change listener.

Parameters:
l - The property change listener.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove a property change listener.

Parameters:
l - The property change listener.

iconForId

public IconTip iconForId(java.lang.String iconId)
Return an icon tip for a given id. Part of the Iconic interface.

Specified by:
iconForId in interface Iconic
Parameters:
iconId - The icon id.
Returns:
The IconTip or null if it doesn't exist.

addIconListener

public void addIconListener(IconListener listener)
Add an icon listener. Part of the Iconic interface.

Specified by:
addIconListener in interface Iconic
Parameters:
listener - The listener.

removeIconListener

public void removeIconListener(IconListener listener)
Remove an icon listener. Part of the Iconic interface.

Specified by:
removeIconListener in interface Iconic
Parameters:
listener - The listener.

destroy

public final void destroy()
Destroy resources. Override onDestroy to do specific resourece clear up.


onDestroy

public void onDestroy()
Subclasses override this method to clear up resources.