Class BaseComponent

java.lang.Object
org.oddjob.framework.extend.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 jobs and services.
Author:
Rob Gordon
  • Constructor Details

    • BaseComponent

      public BaseComponent()
  • Method Details

    • stateHandler

      protected abstract StateHandler<?> stateHandler()
      Subclasses must provide a StateHandler.
      Returns:
      A State Handler. Never null.
    • iconHelper

      protected abstract IconHelper iconHelper()
      Subclasses must provide a IconHelper.
      Returns:
      An Icon Helper. Never null.
    • setArooaSession

      public void setArooaSession(ArooaSession session)
      Here for the tests...
      Specified by:
      setArooaSession in interface ArooaSessionAware
      Parameters:
      session -
    • getArooaSession

      protected ArooaSession getArooaSession()
      Allow sub classes access the the session.
      Returns:
      A session. Will never be null once a component is initialised within Oddjob. May be null if otherwise if the session hasn't been set.
    • setArooaContext

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

      protected abstract org.slf4j.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 for the given component. The given component is normally this component or proxy.
      Parameters:
      component - The component to configure.
      Throws:
      ArooaConfigurationException
    • save

      protected void save(Object component) throws ComponentPersistException
      Save this job. This given component is normally this component or a proxy.
      Parameters:
      component - The component to save.
      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 ImageData 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 Icon Image Data 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. This is called by the framework before child elements have been destroyed.
    • fireDestroyedState

      protected abstract void fireDestroyedState()
      Subclasses must override this to fire the destroyed state. This is called by the framework after all child elements have been destroyed.