AppLife Updates are performed by the AppLife Update Engine. The update engine is responsible for executing the actions defined in the update project. Each action contains the logic necessary to perform its function. In addition to the actual update process, each action is responsible for ensuring that its work can be rolled back in the event of an unexpected exception anywhere in the update process. To support this, the update engine executes multiple stages within the update process. The stages that the engine executes are:
• Prepare
• Execute
• Cleanup
And in the event that an error occurs, a Rollback stage is executed.
The engine first iterates through each action and executes the Prepare stage. The purpose of this stage is to perform any actions necessary to prepare the client for the work to be done in the Execute stage. This might include backing up files that are to be replaced, checking for specific permissions to perform the tasks, etc.
Once each action has performed its Prepare operations, the action list is iterated, with each action performing its Execute operations. When the final action in the action list successfully completes its Execute operation, the update is considered successful. If an exception occurs before reaching this point, the Update Engine will enter a Rollback stage. During a rollback operation, the actions are iterated in reverse order from the action that caused the exception. In each action, the Rollback operations are performed.
Upon successfully completing the Execute phase, the Update Engine iterates the Cleanup phase. Each action can remove any temporary files or perform any other cleanup operations necessary. No actions actually required to update the client should be performed in the Cleanup stage. An exception in this stage will not cause a rollback operation.
Note: When an action has a conditional statement assigned, the action Prepare method is deferred to execute just before the Execute method. When the execute stage reaches the action, the conditional statement is evaluated. Based on the result of evaluating the conditional expression, the prepare stage method will execute immediately before the Execute method.