Package org.oddjob.framework.extend
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIconListener(IconListener listener) Add an icon listener.voidAdd a property change listener.voidaddStateListener(StateListener listener) Add a job state listener.protected voidConfigure the runtime for the given component.voiddestroy()When running a job embedded in code, this method should always be called to clear up resources.protected abstract voidSubclasses must override this to fire the destroyed state.protected voidfirePropertyChange(String propertyName, Object oldValue, Object newValue) Fire a property change event.protected ArooaSessionAllow sub classes access the the session.Return an icon tip for a given id.protected abstract IconHelperSubclasses must provide aIconHelper.voidWhen running a job embedded in code, it may be necessary to call this method to initialise the job.Returns the last JobState event.protected abstract org.slf4j.Loggerlogger()protected voidSubclasses override this method to perform post configuration initialisation.protected voidSubclasses override this method to clear up resources.protected voidSubclasses override this method to perform post creation initialisation.voidremoveIconListener(IconListener listener) Remove an icon listener.voidRemove a property change listener.voidremoveStateListener(StateListener listener) Remove a job state listener.protected voidsave()Implementations override this to save their state on state change.protected voidSave this job.voidsetArooaContext(ArooaContext context) voidsetArooaSession(ArooaSession session) Here for the tests...protected abstract StateHandler<?> Subclasses must provide aStateHandler.
-
Constructor Details
-
BaseComponent
public BaseComponent()
-
-
Method Details
-
stateHandler
Subclasses must provide aStateHandler.- Returns:
- A State Handler. Never null.
-
iconHelper
Subclasses must provide aIconHelper.- Returns:
- An Icon Helper. Never null.
-
setArooaSession
Here for the tests...- Specified by:
setArooaSessionin interfaceArooaSessionAware- Parameters:
session-
-
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
- Specified by:
setArooaContextin interfaceArooaContextAware
-
logger
protected abstract org.slf4j.Logger logger() -
save
Implementations override this to save their state on state change.- Throws:
ComponentPersistException
-
configure
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
Save this job. This given component is normally this component or a proxy.- Parameters:
component- The component to save.- Throws:
ComponentPersistException
-
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:
lastStateEventin interfaceStateful- Returns:
- The last JobStateEvent. Will never be null.
-
addStateListener
Add a job state listener.- Specified by:
addStateListenerin interfaceStateful- Parameters:
listener- The listener.
-
removeStateListener
Remove a job state listener.- Specified by:
removeStateListenerin interfaceStateful- Parameters:
listener- The listener.
-
addPropertyChangeListener
Add a property change listener.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeNotifier- Parameters:
l- The property change listener.
-
removePropertyChangeListener
Remove a property change listener.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeNotifier- Parameters:
l- The property change listener.
-
firePropertyChange
Fire a property change event.- Parameters:
propertyName-oldValue-newValue-
-
iconForId
Return an icon tip for a given id. Part of the Iconic interface. -
addIconListener
Add an icon listener. Part of the Iconic interface.- Specified by:
addIconListenerin interfaceIconic- Parameters:
listener- The listener.
-
removeIconListener
Remove an icon listener. Part of the Iconic interface.- Specified by:
removeIconListenerin interfaceIconic- Parameters:
listener- The listener.
-
initialise
When running a job embedded in code, it may be necessary to call this method to initialise the job.- Throws:
JobDestroyedException
-
destroy
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.
-