Class org.as2lib.app.exec.AbstractProcess

Implemented Interfaces

Process ProcessErrorListener ProcessFinishListener

Description

AbstractProcess is a abstract helper class to implement processes.

Most of the functionalities of Process are served well within AbstractProcess. Because of the situation that most processes are simple executions AbstractProcess allows easy implementations of Process.

To use the advantage of AbstractProcess simple extend it and implement the run method.

It executes run at start and handles the exeuction of events and the correct states. If you wan't to stop your process pause and resume offer direct support.

Example for a process that can not be finished by return: class MyProcess extends AbstractProcess { public function run() { // Xml that has to work var xml:Xml = new Xml(); // helper for the call back. var inst = this; // Mtasc compatible return from loading xml.onLoad = function() { inst["finish"](); } // Flag to not finish automatically working = true; // Start of loading the xml file. xml.load("test.xml"); } }

See Also

Field Index

Inherited from LogSupport

Method Index

getErrors(), getParentProcess(), hasError(), isPaused(), isRunning(), onProcessError(), onProcessFinish(), pause(), resume(), setParentProcess(), start(), startSubProcess()

Inherited from AbstractTimeConsumer

Inherited from EventSupport

Inherited from LogSupport

Inherited from BasicClass

Method Detail

setParentProcess

public function setParentProcess(p:Process):Void

Setter for a parent process.

Validates if the passed-in Process is this instance or has this instance in its parent hierarchy (to prevent recursions).

Parameters

p Process to act as parent

Throws

IllegalArgumentExceptionif the applied process has the current instance in its parent hierarchy or it is the current instance

Specified By

setParentProcess() in org.as2lib.app.exec.Process

getParentProcess

public function getParentProcess(Void):Process

Returns the Process that acts as parent for this process.

Return

parent Process if set, else null

Specified By

getParentProcess() in org.as2lib.app.exec.Process

startSubProcess

public function startSubProcess(process:Process, args:Array, callBack:Executable):Void

Starts a sub-process.

This method allows to start a Process. It registers itself as parent of the passed-in process and starts the process if necessary.

If you add a sub-process it will be started immediately. This is important if you start more than one sub-process, because they won't get executed in a row like its handled within a Batch.

This process will not be finished until all subprocesses have finished.

On finish of the process to start it will execute the passed-in callBack.

Parameters

processprocess to be used as sub-process
argsarguments for the process start
callBackcall back to be executed if the process finishes

pause

public function pause(Void):Void

Pauses the process.

resume

public function resume(Void):Void

Resumes the process.

start

public function start()

Starts the process.

Any applied parameter will be passed to the run implementation.

Return

(optional) result of run()

Specified By

start() in org.as2lib.app.exec.Process

isPaused

public function isPaused(Void):Boolean

Returns true if the process is paused.

Return

true if the process is paused

Specified By

isPaused() in org.as2lib.app.exec.Process

isRunning

public function isRunning(Void):Boolean

Returns true if the process is running.

Return

true if the process is running

Specified By

isRunning() in org.as2lib.app.exec.Process

onProcessFinish

public function onProcessFinish(process:Process):Void

Method to be executed if a process finishes its execution.

Parameters

processProcess that finished with execution

Specified By

onProcessFinish() in org.as2lib.app.exec.ProcessFinishListener

onProcessError

public function onProcessError(process:Process, error):Boolean

Method to be executed if a exception was thrown during the execution.

Parameters

processProcess where a error occured
errorerror that occured

Return

true if error was consumed

Specified By

onProcessError() in org.as2lib.app.exec.ProcessErrorListener

hasError

public function hasError(Void):Boolean

Returns true if a error occured.

Return

true if a error occured

Specified By

hasError() in org.as2lib.app.exec.Process

getErrors

public function getErrors(Void):Array

Returns the list with all occured errors.

Return

list that contains all occured errors

Specified By

getErrors() in org.as2lib.app.exec.Process