org.oddjob.framework
Class SimpleService

java.lang.Object
  extended by org.oddjob.framework.BaseComponent
      extended by org.oddjob.framework.SimpleService
All Implemented Interfaces:
Runnable, ArooaContextAware, ArooaSessionAware, PropertyChangeNotifier, Iconic, LogEnabled, Resetable, Stateful, Stoppable
Direct Known Subclasses:
ClientBase, OddjobPanel

public abstract class SimpleService
extends BaseComponent
implements Runnable, Stateful, Resetable, Stoppable, LogEnabled

Base class for providing a common Service implementation.

Note that this class is only required when special interaction with Oddjob is required such as different state handling. Most simple service can be provided a classes to be proxied.

Author:
rob

Field Summary
protected  ServiceStateHandler stateHandler
           
 
Fields inherited from class org.oddjob.framework.BaseComponent
iconHelper
 
Constructor Summary
SimpleService()
          Constructor.
 
Method Summary
protected  void fireDestroyedState()
          Internal method to fire state.
 String getName()
          Get the name.
protected  ServiceStateChanger getStateChanger()
           
 boolean hardReset()
          Perform a hard reset on the job.
protected  org.apache.log4j.Logger logger()
           
 String loggerName()
          Provide the logger name.
protected  void onDestroy()
          Subclasses override this method to clear up resources.
protected abstract  void onStart()
           
protected  void onStop()
          Allow sub classes to do something on stop.
 void run()
           
 void setName(String name)
          Set the name
 boolean softReset()
          Perform a soft reset on the job.
protected  ServiceStateHandler stateHandler()
           
 void stop()
          Stop executing.
 String toString()
           
 
Methods inherited from class org.oddjob.framework.BaseComponent
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, save, setArooaContext, setArooaSession
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.oddjob.Stateful
addStateListener, lastStateEvent, removeStateListener
 

Field Detail

stateHandler

protected final ServiceStateHandler stateHandler
Constructor Detail

SimpleService

public SimpleService()
Constructor.

Method Detail

logger

protected org.apache.log4j.Logger logger()
Specified by:
logger in class BaseComponent

loggerName

public String loggerName()
Description copied from interface: LogEnabled
Provide the logger name. The name should be unique for each component that is LogEnabled.

Specified by:
loggerName in interface LogEnabled
Returns:
A logger name. Never Null.

stateHandler

protected ServiceStateHandler stateHandler()
Specified by:
stateHandler in class BaseComponent

getStateChanger

protected ServiceStateChanger getStateChanger()

run

public void run()
Specified by:
run in interface Runnable

onStart

protected abstract void onStart()
                         throws Throwable
Throws:
Exception
Throwable

stop

public void stop()
          throws FailedToStopException
Description copied from interface: Stoppable
Stop executing. This method should not return until the Stoppable has actually stopped.

Specified by:
stop in interface Stoppable
Throws:
FailedToStopException

onStop

protected void onStop()
               throws FailedToStopException
Allow sub classes to do something on stop.

Throws:
FailedToStopException

softReset

public boolean softReset()
Perform a soft reset on the job.

Specified by:
softReset in interface Resetable
Returns:
true if successful.

hardReset

public boolean hardReset()
Perform a hard reset on the job.

Specified by:
hardReset in interface Resetable
Returns:
true if successful.

getName

public String getName()
Get the name.

Returns:
The name.

setName

public void setName(String name)
Set the name

Parameters:
name - The name.

toString

public String toString()
Overrides:
toString in class Object

onDestroy

protected void onDestroy()
Description copied from class: BaseComponent
Subclasses override this method to clear up resources.

Overrides:
onDestroy in class BaseComponent

fireDestroyedState

protected void fireDestroyedState()
Internal method to fire state.

Specified by:
fireDestroyedState in class BaseComponent