Project Wonder 5.0

er.extensions.concurrency
Class ERXLongResponseTask.DefaultImplementation

java.lang.Object
  extended by er.extensions.concurrency.ERXLongResponseTask.DefaultImplementation
All Implemented Interfaces:
ERXLongResponseTask, java.lang.Runnable
Enclosing interface:
ERXLongResponseTask

public abstract static class ERXLongResponseTask.DefaultImplementation
extends java.lang.Object
implements java.lang.Runnable, ERXLongResponseTask


Nested Class Summary
 
Nested classes/interfaces inherited from interface er.extensions.concurrency.ERXLongResponseTask
ERXLongResponseTask.DefaultImplementation, ERXLongResponseTask.WorkerThread
 
Field Summary
protected  boolean _cancelled
          Holds the cancel flag
protected  boolean _done
          Holds the done flag
protected  java.lang.Exception _exception
          Exception code
protected  ERXLongResponse _longResponse
          Refresh page that controls this task
protected  java.lang.Object _result
          Result code
protected  java.lang.Object _status
          Status code
protected  java.lang.Thread _thread
          Hold the thread that performs the task
 org.apache.log4j.Logger log
          logging support
 
Constructor Summary
ERXLongResponseTask.DefaultImplementation()
          Constructor
 
Method Summary
protected  void _finishInitialization()
          Sets up the object.
protected  com.webobjects.appserver.WOComponent cancelPageForStatus(java.lang.Object aStatus)
          Override this to return a sensible page to show after the task was stopped.
protected  java.lang.Exception exception()
          Returns the exception that may have occurred in the run() method.
protected  boolean isCancelled()
          Checks if the task was stopped externally.
 boolean isDone()
          (non-Javadoc)
 ERXLongResponse longResponse()
          Returns the long response for this task.
 com.webobjects.appserver.WOComponent nextPage()
          Default implementation that controls the pages returned on each iteration.
protected  com.webobjects.appserver.WOComponent pageForException(java.lang.Exception exception)
          Override this to return an exception page suitable for the given exception.
protected  com.webobjects.appserver.WOComponent pageForResult(java.lang.Object aResult)
          Override this to return the page after the task was completed without beeing stopped.
abstract  java.lang.Object performAction()
          You need to override this and perform your long running task.
protected  com.webobjects.appserver.WOComponent refreshPageForStatus(java.lang.Object aStatus)
          Override this to return and modify the refresh page.
protected  java.lang.Object result()
          The abstract result object that has been returned by performAction().
 void run()
          Implementation of the Runnable interface.
protected  void setException(java.lang.Exception anObject)
          Use this method to flag if an exception page should get displayed after finishing the current step.
 void setLongResponse(ERXLongResponse sender)
          Sets the long response that controls this task.
protected  void setResult(java.lang.Object anObject)
          Abstract result object that will get set when the task is finished.
protected  void setStatus(java.lang.Object anObject)
           
 void start()
          Default implementation of the ERXLongResponseTask.start() method.
 java.lang.Object status()
          Returns a current status.
 void stop()
          Stops the task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public org.apache.log4j.Logger log
logging support


_longResponse

protected ERXLongResponse _longResponse
Refresh page that controls this task


_status

protected java.lang.Object _status
Status code


_result

protected java.lang.Object _result
Result code


_exception

protected java.lang.Exception _exception
Exception code


_cancelled

protected boolean _cancelled
Holds the cancel flag


_done

protected boolean _done
Holds the done flag


_thread

protected java.lang.Thread _thread
Hold the thread that performs the task

Constructor Detail

ERXLongResponseTask.DefaultImplementation

public ERXLongResponseTask.DefaultImplementation()
Constructor

Method Detail

_finishInitialization

protected void _finishInitialization()
Sets up the object.


setLongResponse

public void setLongResponse(ERXLongResponse sender)
Sets the long response that controls this task.

Specified by:
setLongResponse in interface ERXLongResponseTask

longResponse

public ERXLongResponse longResponse()
Returns the long response for this task.


run

public void run()
Implementation of the Runnable interface.

Specified by:
run in interface java.lang.Runnable

status

public java.lang.Object status()
Returns a current status. This can be any object and will given again to you to divine the next step.


setStatus

protected void setStatus(java.lang.Object anObject)

exception

protected java.lang.Exception exception()
Returns the exception that may have occurred in the run() method.


setException

protected void setException(java.lang.Exception anObject)
Use this method to flag if an exception page should get displayed after finishing the current step.

Parameters:
anObject -

result

protected java.lang.Object result()
The abstract result object that has been returned by performAction().


setResult

protected void setResult(java.lang.Object anObject)
Abstract result object that will get set when the task is finished.

Parameters:
anObject -

isCancelled

protected boolean isCancelled()
Checks if the task was stopped externally.

Returns:
true if stop() was called.

isDone

public boolean isDone()
(non-Javadoc)

Specified by:
isDone in interface ERXLongResponseTask
Returns:
true if the task is still running
See Also:
ERXLongResponseTask.isDone()

stop

public void stop()
Stops the task. This just sets the cancel flag. Its up to you to check in your task if you are interruptable. So you should check isCancelled() in your performAction().

Specified by:
stop in interface ERXLongResponseTask

start

public void start()
Default implementation of the ERXLongResponseTask.start() method. Creates a new thread unless there already exists one.

Specified by:
start in interface ERXLongResponseTask

pageForException

protected com.webobjects.appserver.WOComponent pageForException(java.lang.Exception exception)
Override this to return an exception page suitable for the given exception. This implementation just re-throws the exception.

Parameters:
exception -
Returns:
page for the exceptino

refreshPageForStatus

protected com.webobjects.appserver.WOComponent refreshPageForStatus(java.lang.Object aStatus)
Override this to return and modify the refresh page. This is called while the task is still running. Note that is the place where you can call ERXLongResponse.setRefreshInterval(int) to set the next refresh time.

Parameters:
aStatus -

pageForResult

protected com.webobjects.appserver.WOComponent pageForResult(java.lang.Object aResult)
Override this to return the page after the task was completed without beeing stopped. Whether or not this counts as a success should be divined from the result object. This is the same object you return after being asked for result().

Parameters:
aResult - some result object
Returns:
result page for successfu completion

cancelPageForStatus

protected com.webobjects.appserver.WOComponent cancelPageForStatus(java.lang.Object aStatus)
Override this to return a sensible page to show after the task was stopped. The default implementation returns the refresh component's top-level page

Parameters:
aStatus - some status object
Returns:
result page for the cancelled task.

nextPage

public com.webobjects.appserver.WOComponent nextPage()
Default implementation that controls the pages returned on each iteration.

Specified by:
nextPage in interface ERXLongResponseTask
Returns:
next page according to inner status.

performAction

public abstract java.lang.Object performAction()
You need to override this and perform your long running task.

Returns:
result of performing the action

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.