7 Hosted Application Life Cycle

7.1 Initialization

The Hosting System initializes a Hosted Application by issuing a run command or its equivalent (e.g exec function in the C language) with command line parameters to specify the end point references (URLs) to be used for the interfaces. One end point reference is used by the Hosted Application to access the Host interface provided by the Hosting System. The second end point reference is where the Hosting System will look for the Application interface provided by the Hosted Application. The Host and Application interfaces are described in Section 8. If issued from a command prompt or shell, the run command may appear as:

app –-hostURL url1 –-applicationURL url2

Notes: 1. In this startup methodology, it is the Hosting System, not the Hosted Application that specifies both URLs. The Hosted Application must respond at the URL assigned to it by the Hosting System.

2. A Hosted Application implementation where the Hosted Application runs remotely or on an application server might utilize a startup or proxy application to appropriately map between the URL provided by the Hosting System and the actual URL that the Hosted Application is using.

Figure 7.1-1 shows a sequence diagram of Hosted Application initialization. Once the Hosted Application has initialized and is ready to begin processing data, it changes its state to IDLE and notifies the Hosting System of the state change using a call to the notifyStateChanged() method, thus informing the Hosting System that the Hosted Application is ready to go.

[pic]

Figure 7.1-1 Hosted Application Initialization Sequence

7.2 States

Figure 7.2-1 shows the state diagram for a Hosted Application. The following states are defined:

State Description
IDLE In IDLE state the Hosted Application is waiting for a new task assignment from the Hosting System. This is the initial state when the Hosted Application starts.
INPROGRESS The Hosted Application is performing the assigned task.
SUSPENDED The Hosted Application is stopping processing and is releasing as many resources as it can, while still preserving enough state to be able to resume processing.
COMPLETED The Hosted Application has completed processing, and is waiting for the Hosting System to access and release any output data from Hosted Application.
CANCELED The Hosted Application is stopping processing, and is releasing all resources with no chance to resume processing.
EXIT The terminal state of the Hosted Application.

The transitions between states are:

State Trigger New State
not started Hosting System launches the Hosted Application (e.g. run, exec). IDLE
IDLE Hosting System calls Application.setState (EXIT). EXIT
IDLE Hosting System calls Application.setState (INPROGRESS). INPROGRESS
INPROGRESS Hosting System calls Application.setState (SUSPENDED). SUSPENDED
INPROGRESS Hosting System calls Application.setState (CANCELED). CANCELED
INPROGRESS Hosted Application encounters an error that prevents further processing, but is still healthy enough to perhaps start another task. The Hosted Application shall report this error through a call to notifyStatus() with a statusType of FATALERROR prior to transitioning to the CANCELED state. CANCELED
INPROGRESS Hosted Application finishes its processing. COMPLETED
SUSPENDED Hosting System calls Application.setState (INPROGRESS). INPROGRESS
SUSPENDED Hosted Application encounters an error (e.g. during suspension) that prevents further processing, but is still healthy enough to perhaps start another task. The Hosted Application shall report this error through a call to notifyStatus() with a statusType of FATALERROR prior to transitioning to the CANCELED state. CANCELED
SUSPENDED Hosting System calls Application.setState (CANCELED). CANCELED
COMPLETED Hosting System calls Application.setState (IDLE), after capturing all pertinent output data from the Hosted Application. IDLE
CANCELED Hosted Application releases all resources and is ready for the next task. IDLE

The Hosted Application notifies the Hosting System of all state transitions by calling the notifyStateChanged() method.

Note: If a Hosted Application does not respond to state change requests made by the Hosting System, the Hosting System may ‘hard abort’ the Hosted Application in some implementation specific manner, such as by killing the process in which the Hosted Application is executing.

[pic]

Figure 7.2-1 State Diagram of Hosted Applications.