org.oddjob.jobs
Class GrabJob

java.lang.Object
  extended by org.oddjob.framework.BaseComponent
      extended by org.oddjob.framework.BasePrimary
          extended by org.oddjob.jobs.GrabJob
All Implemented Interfaces:
Serializable, Runnable, ArooaContextAware, ArooaSessionAware, PropertyChangeNotifier, Iconic, LogEnabled, Resetable, Stateful, Stoppable, Structural

public class GrabJob
extends BasePrimary
implements Runnable, Serializable, Stoppable, Resetable, Stateful, Structural

Description

Grab work to do. By competing for work with other Grabbers this job facilitates distribution of work between multiple Oddjob processes.

Example

See the user guide.
See Also:
Serialized Form
Author:
rob

Nested Class Summary
static class GrabJob.LoosingAction
          Actions on loosing.
 
Field Summary
protected  boolean stop
           
 
Fields inherited from class org.oddjob.framework.BaseComponent
iconHelper
 
Constructor Summary
GrabJob()
          Constructor.
 
Method Summary
 void addStructuralListener(StructuralListener listener)
          Add a listener.
protected  void fireDestroyedState()
          Internal method to fire state.
 String getIdentifier()
           
 Object getInstance()
           
 GrabJob.LoosingAction getOnLoosing()
           
protected  StateChanger<JobState> getStateChanger()
           
 String getWinner()
           
 boolean hardReset()
          Perform a hard reset on the job.
 void removeStructuralListener(StructuralListener listener)
          Remove a listener.
 void run()
           
 void setIdentifier(String identifier)
           
 void setInstance(Object instance)
           
 void setJob(Runnable job)
          The child.
 void setKeeper(Keeper keeper)
           
 void setOnLoosing(GrabJob.LoosingAction loosingAction)
           
 boolean softReset()
          Perform a soft reset on the job.
protected  JobStateHandler stateHandler()
           
 void stop()
          Stop executing.
 
Methods inherited from class org.oddjob.framework.BasePrimary
configure, getName, logger, logger, loggerName, save, setName, toString
 
Methods inherited from class org.oddjob.framework.BaseComponent
addIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onDestroy, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, 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

stop

protected transient volatile boolean stop
Constructor Detail

GrabJob

public GrabJob()
Constructor.

Method Detail

stateHandler

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

getStateChanger

protected StateChanger<JobState> getStateChanger()

run

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

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

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.

addStructuralListener

public void addStructuralListener(StructuralListener listener)
Add a listener. The listener will immediately receive add notifications for all existing children.

Specified by:
addStructuralListener in interface Structural
Parameters:
listener - The listener.

removeStructuralListener

public void removeStructuralListener(StructuralListener listener)
Remove a listener.

Specified by:
removeStructuralListener in interface Structural
Parameters:
listener - The listener.

setJob

public void setJob(Runnable job)
The child.

Property: job

Description: The child job.

Required: No, but pointless if missing.

Parameters:
job - A child

setKeeper

public void setKeeper(Keeper keeper)

getIdentifier

public String getIdentifier()

setIdentifier

public void setIdentifier(String identifier)

getInstance

public Object getInstance()

setInstance

public void setInstance(Object instance)

getWinner

public String getWinner()

getOnLoosing

public GrabJob.LoosingAction getOnLoosing()

setOnLoosing

public void setOnLoosing(GrabJob.LoosingAction loosingAction)

fireDestroyedState

protected void fireDestroyedState()
Internal method to fire state.

Specified by:
fireDestroyedState in class BaseComponent