com.developmentontheedge.jobcontrol
Class FunctionJobControl

java.lang.Object
  extended bycom.developmentontheedge.jobcontrol.AbstractJobControl
      extended bycom.developmentontheedge.jobcontrol.FunctionJobControl
All Implemented Interfaces:
JobControl, java.lang.Runnable
Direct Known Subclasses:
SimulatorJobControl

public class FunctionJobControl
extends AbstractJobControl

Provides JobControl functionality for long time performed functions FunctionJobControl is intended for control of function processing. Here the stub demonstrating how FunctionJobControl should be used:

 public void function(functionArgumnts, FunctionJobControl control) throws JobControlException
 {
      try
      {

          if(control != null)
              control.functionStarted();
          for(...)
          {
              if(control != null)
                  control.checkStatus();
              ...
              if(control != null)
                  control.setPreparedness( % );
          }
          if(control != null)
              control.functionFinished();
       }
       catch(Throwable t)
       {
           if(control != null)
               functionTerminatedByError(t);
       }
 }
 


Field Summary
protected static org.apache.log4j.Category log
           
 
Fields inherited from class com.developmentontheedge.jobcontrol.AbstractJobControl
cat, isTerminated, preparedness, runStatus, startedDate, status
 
Fields inherited from interface com.developmentontheedge.jobcontrol.JobControl
COMPLETED, CREATED, PAUSED, RUNNING, TERMINATED_BY_ERROR, TERMINATED_BY_REQUEST
 
Constructor Summary
FunctionJobControl(org.apache.log4j.Category cat)
          Constructs FunctionJobControl
FunctionJobControl(org.apache.log4j.Category cat, JobControlListener l)
          Constructs FunctionJobControl
 
Method Summary
protected  void doRun()
          Empty implementation
 void functionFinished()
          This method should be called when Job is finished successfuly
 void functionFinished(java.lang.String msg)
          This method should be called when Job is finished successfuly
 void functionStarted()
          This method should be called when Job is started
 void functionStarted(java.lang.String msg)
          This method should be called when Job is started
 void functionTerminatedByError(java.lang.Throwable t)
          This method should be called when Job is finished by error
 
Methods inherited from class com.developmentontheedge.jobcontrol.AbstractJobControl
addListener, begin, begin, checkStatus, end, end, exceptionOccured, fireJobPaused, fireJobResumed, fireJobStarted, fireJobTerminated, fireValueChanged, format, format, getCreatedTime, getElapsedTime, getEndedTime, getPreparedness, getRemainedTime, getStartedTime, getStatus, getTextStatus, isStatusTerminated, pause, reset, resetFlags, resultsAreReady, resume, run, setCompleted, setPreparedness, setTerminated, terminate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Category log
Constructor Detail

FunctionJobControl

public FunctionJobControl(org.apache.log4j.Category cat)
Constructs FunctionJobControl

Parameters:
cat - logging Category

FunctionJobControl

public FunctionJobControl(org.apache.log4j.Category cat,
                          JobControlListener l)
Constructs FunctionJobControl

Parameters:
cat - logging Category
Method Detail

functionStarted

public void functionStarted()
This method should be called when Job is started


functionStarted

public void functionStarted(java.lang.String msg)
This method should be called when Job is started

Parameters:
msg - detailed message. This message is used for creating of JobControlEvent
See Also:
JobControlEvent

functionFinished

public void functionFinished(java.lang.String msg)
This method should be called when Job is finished successfuly

Parameters:
msg - detailed message. This message is used for creating of JobControlEvent

functionFinished

public void functionFinished()
This method should be called when Job is finished successfuly


functionTerminatedByError

public void functionTerminatedByError(java.lang.Throwable t)
This method should be called when Job is finished by error

Parameters:
t - exception that is occured during Job process

doRun

protected void doRun()
              throws JobControlException
Empty implementation

Specified by:
doRun in class AbstractJobControl
Throws:
JobControlException


Copyright © 2001-2003 Biosof.Ru. All Rights Reserved.