com.im.commons.nbcommons 5.9

com.im.commons.progress
Class BackgroundRunner

java.lang.Object
  extended by com.im.commons.progress.BackgroundRunner

public abstract class BackgroundRunner
extends Object

The utility class which supports running of some task in request processor and after finishing transfer the code flow to AWT thread. It can be used also for delayed task running, but in this case override getRequestProcessor() method to return some RP with only one task running simultaneously.


Constructor Summary
BackgroundRunner()
           
BackgroundRunner(int delay)
           
 
Method Summary
protected  RequestProcessor.Task createTask()
           
protected  void failTask(Exception exc)
          Finishes the task with the failure report passed as a parameter.
protected  Object getCreateLock()
           
protected  int getDelay()
           
protected  RequestProcessor getRequestProcessor()
          Which RP to use for running tasks.
 RequestProcessor.Task getTask()
           
 void interrupt()
           
 boolean phase1Cancelled(CancelException exc)
           
 boolean phase1Exception(Exception exc)
          All subclasses must override this method and provide more user-friendly error notification.
 void phase1Finally()
           
protected  void phase1FinallyInternal()
           
abstract  void phase1InRequestProcessor()
          This method code is executed in request processor.
 void phase2InAWT()
          This method code is executed in AWT thread after phase1 finishes.
protected  void processTheTask()
           
 void restart()
           
 RequestProcessor.Task start()
          Start runner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BackgroundRunner

public BackgroundRunner()

BackgroundRunner

public BackgroundRunner(int delay)
Method Detail

start

public RequestProcessor.Task start()
Start runner.

Returns:
The background task handle.

getCreateLock

protected final Object getCreateLock()
Returns:
The locking object that guards creation of a new task. Use when you need to query task or other things computed during start()

createTask

protected RequestProcessor.Task createTask()
Returns:
The locking object that guards creation of a new task. Use when you need to query task or other things computed during start()

failTask

protected final void failTask(Exception exc)
Finishes the task with the failure report passed as a parameter. The call sequence should be the same as if the task failed in its run() method. Note that during this call, the DFEnvironment may use a fake lock in the case that locking the DIF object has failed.

Parameters:
exc - The failure

processTheTask

protected final void processTheTask()

interrupt

public void interrupt()

getDelay

protected int getDelay()

getRequestProcessor

protected RequestProcessor getRequestProcessor()
Which RP to use for running tasks. It's possible to return e.g. RP running only one task at once.


restart

public void restart()

getTask

public RequestProcessor.Task getTask()

phase1InRequestProcessor

public abstract void phase1InRequestProcessor()
This method code is executed in request processor.


phase2InAWT

public void phase2InAWT()
This method code is executed in AWT thread after phase1 finishes.


phase1Cancelled

public boolean phase1Cancelled(CancelException exc)
Returns:
when true this runner continues with AWT (second) phase. If false, the AWT phase is skipped.

phase1Exception

public boolean phase1Exception(Exception exc)
All subclasses must override this method and provide more user-friendly error notification.

Returns:
when true this runner continues with AWT (second) phase. If false, the AWT phase is skipped.

phase1FinallyInternal

protected void phase1FinallyInternal()

phase1Finally

public void phase1Finally()

com.im.commons.nbcommons 5.9