When writing a process it is important to understand how processes fit into the architectural framework of AwareIM. When a process is started AwareIM creates the execution context, which contains the information about the environment in which the process is running. This information contains the data about the user who started the process, the process start-up time, the information about the current database transaction as well as many other things. The execution context is available to the process as the IExecutionContext interface. Because a process in AwareIM runs in a “sandbox” there are certain limitations on what the process can do (see guidelines later in this section).
A process communicates with AwareIM through the call-back interface called IExecutionEngine. This interface has a variety of methods that a process can use to change attributes of objects, start other processes, call services of service providers etc.
Sometimes a particular process calls a service, which takes a long time to fulfil. In this case the call to the service may time out. If this happens the process is suspended. This means that AwareIM moves the process into the “standby” mode – it is no longer active and is waiting for the reply from the service provider. Whenever such reply arrives (the reply may arrive in a few seconds, hours, days or months or never arrive at all) AwareIM automatically resumes the process and the process continues execution from where it left off.
The custom process component must implement IProcess
interface, which has two main methods – execute and resume. The execute method is called when the process is started and the resume method is called when the process is resumed after having been suspended. Both methods are described in detail later in the section.
The following guidelines should be used when writing a process:
SuspendProcessException
and sets its resumeImmediately
flag to true, for example: throw new SuspendProcessException (true)
Before doing so the process should obviously remember its current state so that it can correctly resume itself in the resume method.
ServerTimeOutException
the process is supposed to catch this exception and throw SuspendProcessException
passing the original ServerTimeOutException
to the SuspendProcessException
, for example:try { engine.updateEntity (this, entity, null, null); } catch (ServerTimeOutException se) { throw new SuspendProcessException (se); }
The methods of the IProcess
interface that the custom process components must implement are described below:
execute (IExecutionEngine, Object [])
resume (IExecutionEngine, Object [])