public abstract static class ERXLongResponseTask.DefaultImplementation extends Object implements Runnable, ERXLongResponseTask
ERXLongResponseTask.DefaultImplementation, ERXLongResponseTask.WorkerThread
Modifier and Type | Field and Description |
---|---|
protected boolean |
_cancelled
Holds the cancel flag
|
protected boolean |
_done
Holds the done flag
|
protected Exception |
_exception
Exception code
|
protected ERXLongResponse |
_longResponse
Refresh page that controls this task
|
protected Object |
_result
Result code
|
protected Object |
_status
Status code
|
protected Thread |
_thread
Hold the thread that performs the task
|
Logger |
log
logging support
|
Constructor and Description |
---|
DefaultImplementation()
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected void |
_finishInitialization()
Sets up the object.
|
protected com.webobjects.appserver.WOComponent |
cancelPageForStatus(Object aStatus)
Override this to return a sensible page to show after the
task was stopped.
|
protected 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.
|
protected com.webobjects.eocontrol.EOEditingContext |
newEditingContext()
You must manually lock and unlock the editing context returned by
this method. It is not recommended that you depend on auto
locking in background threads.
|
com.webobjects.appserver.WOComponent |
nextPage()
Default implementation that controls the pages returned on each iteration.
|
protected com.webobjects.appserver.WOComponent |
pageForException(Exception exception)
Override this to return an exception page suitable for the
given exception.
|
protected com.webobjects.appserver.WOComponent |
pageForResult(Object aResult)
Override this to return the page after the task was completed without
beeing stopped.
|
protected com.webobjects.eocontrol.EOObjectStore |
parentObjectStore()
See Effective Java item #71 for explanation of this threadsafe lazy
initialization technique
|
abstract Object |
performAction()
You need to override this and perform your long running task.
|
protected com.webobjects.appserver.WOComponent |
refreshPageForStatus(Object aStatus)
Override this to return and modify the refresh page.
|
protected Object |
result()
The abstract result object that has been returned by
performAction() . |
void |
run()
Implementation of the
Runnable interface. |
protected void |
setException(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.
|
void |
setParentObjectStore(com.webobjects.eocontrol.EOObjectStore parentObjectStore) |
protected void |
setResult(Object anObject)
Abstract result object that will get set when the task is finished.
|
protected void |
setStatus(Object anObject) |
void |
start()
Default implementation of the
ERXLongResponseTask.start() method. |
Object |
status()
Returns a current status.
|
void |
stop()
Stops the task.
|
protected long |
taskEditingContextTimestampLag()
By design EOEditingContext's have a fetch timestamp (default is 1 hour)
that effectively creates an in-memory caching system for EOs.
|
public Logger log
protected ERXLongResponse _longResponse
protected Object _status
protected Object _result
protected Exception _exception
protected boolean _cancelled
protected boolean _done
protected Thread _thread
protected void _finishInitialization()
public void setLongResponse(ERXLongResponse sender)
setLongResponse
in interface ERXLongResponseTask
public ERXLongResponse longResponse()
public void run()
Runnable
interface.public Object status()
protected void setStatus(Object anObject)
protected Exception exception()
run()
method.protected void setException(Exception anObject)
anObject
- protected Object result()
performAction()
.protected void setResult(Object anObject)
anObject
- protected boolean isCancelled()
stop()
was called.public boolean isDone()
isDone
in interface ERXLongResponseTask
ERXLongResponseTask.isDone()
public void stop()
isCancelled()
in your performAction()
.stop
in interface ERXLongResponseTask
public void start()
ERXLongResponseTask.start()
method.
Creates a new thread unless there already exists one.start
in interface ERXLongResponseTask
protected com.webobjects.appserver.WOComponent pageForException(Exception exception)
exception
- protected com.webobjects.appserver.WOComponent refreshPageForStatus(Object aStatus)
ERXLongResponse.setRefreshInterval(int)
to
set the next refresh time.aStatus
- protected com.webobjects.appserver.WOComponent pageForResult(Object aResult)
result()
.aResult
- some result objectprotected com.webobjects.appserver.WOComponent cancelPageForStatus(Object aStatus)
aStatus
- some status objectpublic com.webobjects.appserver.WOComponent nextPage()
nextPage
in interface ERXLongResponseTask
public abstract Object performAction()
protected final com.webobjects.eocontrol.EOObjectStore parentObjectStore()
EOObjectStoreCoordinator
to
partition the task's EOF intensive work form the rest of the app.public final void setParentObjectStore(com.webobjects.eocontrol.EOObjectStore parentObjectStore)
parentObjectStore
- the parent, usually an EOObjectStoreCoordinator
to
partition the task's EOF intensive work from the rest of the
app. If you are going to manually set this, you should do it
before starting the task.protected com.webobjects.eocontrol.EOEditingContext newEditingContext()
protected long taskEditingContextTimestampLag()
Copyright © 2002 – 2020 Project Wonder.