org.oddjob.framework
Class BaseComponent

java.lang.Object
  extended by org.oddjob.framework.BaseComponent
All Implemented Interfaces:
ArooaContextAware, ArooaSessionAware, PropertyChangeNotifier, Iconic, Stateful
Direct Known Subclasses:
BasePrimary, BaseWrapper, SimpleService

public abstract class BaseComponent
extends Object
implements Iconic, Stateful, ArooaSessionAware, ArooaContextAware, PropertyChangeNotifier

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

Author:
Rob Gordon

Field Summary
protected  IconHelper iconHelper
          Used to notify clients of an icon change.
 
Constructor Summary
BaseComponent()
           
 
Method Summary
 void addIconListener(IconListener listener)
          Add an icon listener.
 void addPropertyChangeListener(PropertyChangeListener l)
          Add a property change listener.
 void addStateListener(StateListener listener)
          Add a job state listener.
protected  void configure(Object component)
          Configure the runtime.
 void destroy()
          When running a job embedded in code, this method should always be called to clear up resources.
protected abstract  void fireDestroyedState()
          Subclasses must override this to fire the destroyed state.
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          Fire a property change event.
protected  ArooaSession getArooaSession()
           
 ImageIcon iconForId(String iconId)
          Return an icon tip for a given id.
 void initialise()
          When running a job embedded in code, it may be necessary to call this method to initialise the job.
 StateEvent lastStateEvent()
          Returns the last JobState event.
protected abstract  org.apache.log4j.Logger logger()
           
protected  void onConfigured()
          Subclasses override this method to perform post configuration initialisation.
protected  void onDestroy()
          Subclasses override this method to clear up resources.
protected  void onInitialised()
          Subclasses override this method to perform post creation initialisation.
 void removeIconListener(IconListener listener)
          Remove an icon listener.
 void removePropertyChangeListener(PropertyChangeListener l)
          Remove a property change listener.
 void removeStateListener(StateListener listener)
          Remove a job state listener.
protected  void save()
          Implementations override this to save their state on state change.
protected  void save(Object o)
          Save this job.
 void setArooaContext(ArooaContext context)
           
 void setArooaSession(ArooaSession session)
          Here for the tests...
protected abstract  StateHandler<?> stateHandler()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iconHelper

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

Constructor Detail

BaseComponent

public BaseComponent()
Method Detail

stateHandler

protected abstract StateHandler<?> stateHandler()

setArooaSession

public void setArooaSession(ArooaSession session)
Here for the tests...

Specified by:
setArooaSession in interface ArooaSessionAware
Parameters:
session -

getArooaSession

protected ArooaSession getArooaSession()

setArooaContext

public void setArooaContext(ArooaContext context)
Specified by:
setArooaContext in interface ArooaContextAware

logger

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

save

protected void save()
             throws ComponentPersistException
Implementations override this to save their state on state change.

Throws:
ComponentPersistException

configure

protected void configure(Object component)
                  throws ArooaConfigurationException
Configure the runtime. If there is no runtime for this component then true is returned.

Throws:
ArooaConfigurationException

save

protected void save(Object o)
             throws ComponentPersistException
Save this job. If there is no runtime for this component then true is returned.

Throws:
ComponentPersistException

lastStateEvent

public StateEvent lastStateEvent()
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.

Specified by:
lastStateEvent in interface Stateful
Returns:
The last JobStateEvent. Will never be null.

addStateListener

public void addStateListener(StateListener listener)
Add a job state listener.

Specified by:
addStateListener in interface Stateful
Parameters:
listener - The listener.

removeStateListener

public void removeStateListener(StateListener listener)
Remove a job state listener.

Specified by:
removeStateListener in interface Stateful
Parameters:
listener - The listener.

addPropertyChangeListener

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

Specified by:
addPropertyChangeListener in interface PropertyChangeNotifier
Parameters:
l - The property change listener.

removePropertyChangeListener

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

Specified by:
removePropertyChangeListener in interface PropertyChangeNotifier
Parameters:
l - The property change listener.

firePropertyChange

protected void firePropertyChange(String propertyName,
                                  Object oldValue,
                                  Object newValue)
Fire a property change event.

Parameters:
propertyName -
oldValue -
newValue -

iconForId

public ImageIcon iconForId(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.

initialise

public void initialise()
                throws JobDestroyedException
When running a job embedded in code, it may be necessary to call this method to initialise the job.

Throws:
JobDestroyedException

destroy

public void destroy()
             throws JobDestroyedException
When running a job embedded in code, this method should always be called to clear up resources.

Throws:
JobDestroyedException

onInitialised

protected void onInitialised()
Subclasses override this method to perform post creation initialisation.


onConfigured

protected void onConfigured()
Subclasses override this method to perform post configuration initialisation.


onDestroy

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


fireDestroyedState

protected abstract void fireDestroyedState()
Subclasses must override this to fire the destroyed state.