org.oddjob.persist
Class ArchiveJob

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

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

Description

A Job that is capable of taking a snapshot of the state of it's child jobs. An ArchiveBrowserJob can be used to browse an archive created with this job.

Example

Create an archive after each scheduled run. The time of the schedule is used to identify the archive.
<oddjob id="this">
    <job>
        <sequential>
            <jobs>
                <scheduling:timer id="the-timer" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling">
                    <schedule>
                        <schedules:count count="3" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
                        	<refinement>
                        		<schedules:interval interval="00:00:00.100"/>
                        	</refinement>
                        </schedules:count>
                    </schedule>
                    <job>
                    	<archive archiveName="Batch_01">
                    		<archiver>
                    			<file-persister dir="${this.args[0]}"/>
                    		</archiver>
                    	    <archiveIdentifier>
                    	    	<format date="${the-timer.current.fromDate}" format="mm_ss_SSS"/>
                    	    </archiveIdentifier>
                    		<job>
		                        <echo>Run at ${the-timer.current.fromDate}</echo>
                        	</job>
                        </archive>
                    </job>
                </scheduling:timer>
            </jobs>
        </sequential>
    </job>
</oddjob>
See Also:
Serialized Form
Author:
rob

Field Summary
protected  boolean stop
          Stop flag.
 
Fields inherited from class org.oddjob.framework.BaseComponent
iconHelper
 
Constructor Summary
ArchiveJob()
          Constructor.
 
Method Summary
 void addStructuralListener(StructuralListener listener)
          Add a listener.
protected  void execute()
           
protected  void fireDestroyedState()
          Internal method to fire state.
 Object getArchiveIdentifier()
           
 String getArchiveName()
           
 OddjobPersister getArchiver()
           
protected  StateChanger<ParentState> getStateChanger()
           
 boolean hardReset()
          Perform a hard reset on the job.
 void removeStructuralListener(StructuralListener listener)
          Remove a listener.
 void run()
          Implement the main execute method for a job.
 void setArchiveIdentifier(Object archive)
           
 void setArchiveName(String path)
           
 void setArchiver(OddjobPersister archiver)
           
 void setJob(Runnable job)
           
 boolean softReset()
          Perform a soft reset on the job.
protected  ParentStateHandler stateHandler()
           
 void stop()
          Implementation for a typical stop.
 
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
Stop flag.

Constructor Detail

ArchiveJob

public ArchiveJob()
Constructor.

Method Detail

stateHandler

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

getStateChanger

protected StateChanger<ParentState> getStateChanger()

run

public final void run()
Implement the main execute method for a job. This surrounds the doExecute method of the sub class and sets state for the job.

Specified by:
run in interface Runnable

execute

protected void execute()
                throws Throwable
Throws:
Throwable

stop

public void stop()
          throws FailedToStopException
Implementation for a typical stop.

This stop implementation doesn't check that the job is executing as stop messages must cascade down the hierarchy to manually started jobs.

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.

getArchiveIdentifier

public Object getArchiveIdentifier()

setArchiveIdentifier

public void setArchiveIdentifier(Object archive)

getArchiveName

public String getArchiveName()

setArchiveName

public void setArchiveName(String path)

getArchiver

public OddjobPersister getArchiver()

setArchiver

public void setArchiver(OddjobPersister archiver)

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)

Property: job

Description: The child job.

Required: No, but pointless if missing.

Parameters:
job -

fireDestroyedState

protected void fireDestroyedState()
Internal method to fire state.

Specified by:
fireDestroyedState in class BaseComponent