|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.developmentontheedge.jobcontrol.AbstractJobControl
AbstractJobControl is default implementation of JobControl interface. AbstractJobControl provides base functionality of all methods of JobControl
| Field Summary | |
protected org.apache.log4j.Category |
cat
The log4j.Category to print logs. |
protected boolean |
isTerminated
|
protected int |
preparedness
|
protected int |
runStatus
deferred current status of job control |
protected java.util.Date |
startedDate
|
protected int |
status
Current status of JobControl |
| Fields inherited from interface com.developmentontheedge.jobcontrol.JobControl |
COMPLETED, CREATED, PAUSED, RUNNING, TERMINATED_BY_ERROR, TERMINATED_BY_REQUEST |
| Constructor Summary | |
AbstractJobControl(org.apache.log4j.Category cat)
Constructs JobControl with specified Category |
|
AbstractJobControl(org.apache.log4j.Category cat,
JobControlListener listener)
Constructs JobControl with specified Category and JobControlListener |
|
| Method Summary | |
void |
addListener(JobControlListener listener)
Adds JobControlListener object |
void |
begin()
Derived classes should call this method when they want to start controlled process |
protected void |
begin(java.lang.String msg)
Derived classes should call this method when they want to start controlled process with any message |
void |
checkStatus()
Tests status of job control. |
protected abstract void |
doRun()
This method should implement derived classess for real controlled process running |
void |
end()
Sets state defined by runStatus variable. |
protected void |
end(java.lang.String msg)
Sets state defined by runStatus variable. |
protected void |
exceptionOccured(JobControlException ex)
Sets variable runStatus to the current status of job control Call this method when changing of state is needed |
protected void |
fireJobPaused()
Notifies all listeners that job is paused. |
protected void |
fireJobResumed()
Notifies all listeners that job is resumed |
protected void |
fireJobStarted(java.lang.String msg)
Notifies all listeners that job is started. |
protected void |
fireJobTerminated(java.lang.String msg)
Notifies all listeners that job is terminated. |
void |
fireValueChanged()
Notifies all listeners that value returned by getPreparedness() is changed |
static java.lang.String |
format(long time)
Converts time to the string |
static java.lang.String |
format(long time,
java.lang.String format)
Converts time to the specified format string |
long |
getCreatedTime()
Returns JobControl created time. |
long |
getElapsedTime()
Returns elapsed time of Job |
long |
getEndedTime()
Returns Job finished time |
int |
getPreparedness()
Returns preparedness of Job in percent |
long |
getRemainedTime()
Returns estimated remained time |
long |
getStartedTime()
Returns Job start time |
int |
getStatus()
Returns status of Job |
java.lang.String |
getTextStatus()
Returns string representation of Job status |
protected boolean |
isStatusTerminated()
Returns whether status is terminated |
void |
pause()
Sets status of job control to the JobControl.PAUSED state |
protected void |
reset()
Sets status of job in JobControl.CREATED state |
protected void |
resetFlags()
Sets isTerminated,isPaused variables to false |
void |
resultsAreReady()
|
void |
resume()
Sets status of job control to the JobControl.RUNNING state |
void |
run()
Starts the job control process |
protected void |
setCompleted()
Sets JobControl.COMPLETED state of job status |
void |
setPreparedness(int percent)
Sets value of job Preparednes |
protected void |
setTerminated(int status)
Sets status of JobControl |
void |
terminate()
Sets status of job control to the JobControl.TERMINATED_BY_REQUEST state |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected org.apache.log4j.Category cat
log4j.Category to print logs.
protected java.util.Date startedDate
protected int status
protected int runStatus
protected int preparedness
protected boolean isTerminated
| Constructor Detail |
public AbstractJobControl(org.apache.log4j.Category cat)
cat - log Category of log4j package
public AbstractJobControl(org.apache.log4j.Category cat,
JobControlListener listener)
cat - log Category of log4j packagelistener - specified JobControlListener| Method Detail |
protected abstract void doRun()
throws JobControlException
JobControlException - If the process wants to stop the task,or error is occured.public void begin()
protected void begin(java.lang.String msg)
msg - is used for listeners notificationprotected void exceptionOccured(JobControlException ex)
ex - JobControlException sended exceptionprotected boolean isStatusTerminated()
public void end()
protected void end(java.lang.String msg)
msg - specified messagepublic void run()
run in interface java.lang.Runnablepublic void pause()
JobControl.PAUSED state
pause in interface JobControlpublic void resume()
JobControl.RUNNING state
resume in interface JobControlpublic void terminate()
JobControl.TERMINATED_BY_REQUEST state
terminate in interface JobControlpublic int getStatus()
JobControl
getStatus in interface JobControlpublic java.lang.String getTextStatus()
JobControl
getTextStatus in interface JobControlpublic int getPreparedness()
JobControl
getPreparedness in interface JobControlpublic long getCreatedTime()
JobControl
getCreatedTime in interface JobControlpublic long getStartedTime()
JobControl
getStartedTime in interface JobControlpublic long getEndedTime()
JobControl
getEndedTime in interface JobControlpublic long getElapsedTime()
JobControl
getElapsedTime in interface JobControlpublic long getRemainedTime()
JobControl
getRemainedTime in interface JobControlpublic void addListener(JobControlListener listener)
JobControl
addListener in interface JobControllistener - added listenerprotected void fireJobStarted(java.lang.String msg)
msg - notified messageprotected void fireJobPaused()
protected void fireJobResumed()
public void fireValueChanged()
getPreparedness() is changed
protected void fireJobTerminated(java.lang.String msg)
msg - notified messageprotected void setTerminated(int status)
status - terminated status JobControl.TERMINATED_BY_ERROR,JobControl.TERMINATED_BY_REQUESTpublic void setPreparedness(int percent)
percent - percent of job Preparednesspublic void resultsAreReady()
protected void setCompleted()
JobControl.COMPLETED state of job status
protected void reset()
JobControl.CREATED state
protected void resetFlags()
public void checkStatus()
throws JobControlException
JobControlExceptionpublic static java.lang.String format(long time)
time - Unix time
public static java.lang.String format(long time,
java.lang.String format)
time - Unix timeformat - convert format
SimpleDateFormat
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||