| (This document is working in progress). Main ScenariosDeploymentThe basic deployment phases are: prepare, load, start. EnableAll three phases (prepare, load, start) will be invoked on the enabled target. Create application refAll three phases (prepare, load, start) will be invoked on the create-application-ref command target. Application loading in server startAll three phases (prepare, load, start) will be invoked on the referenced server instance. UndeploymentThe basic undeployment phases are: stop, unload, clean. DisableThe stop and unload phases will be invoked on the disabled target. Delete application refThe stop and unload phases will be invoked on the disabled target. Application unloading in server shutdownThe stop and unload phases will be invoked on the referenced server instance. Deployment EventsOther than the formal Deployment/Container SPI , there is also the lightweight event mechanism to hook into the deployment framework. During the deployment lifecycle, there are events sent at each main phase, such as after application is prepared, after the application is loaded, after the application is started etc. A class could be registered as an event listener and take certain actions upon receiving the event. The main events are sent from these classes during deployment lifecycle: 2. v3/common/internal-api/src/main/java/org/glassfish/internal/data/ApplicationInfo.java 3. v3/common/internal-api/src/main/java/org/glassfish/internal/data/ModuleInfo.java The application loading/starting events are sent from ApplicationInfo and module level loading/starting events are sent from ModuleInfo. The ApplicationLifecycle sends the rest of the events. In the event sent from ApplicationLifecycle, the hook object from the event is the DeploymentContext, while the hook object sent from the event sent from ApplicationInfo/ModuleInfo classes are ApplicationInfo and ModuleInfo objects. The application information could be obtained from these hook objects. An event could be synchronous or asynchronous, the events used in the above examples have "false" as the last param which means they are synchronous events. To become an event listener: Some of the examples for the listener classes: Offline ModeDeploymentWhen the target instances are offline, the deployment operation will execute on DAS first. And when the target instances are back up on line, the instances will synchronize with the DAS for the domain.xml and the application bits. As part of the synchronization, the relevant application entries will be added to the instances domain.xml and the applications bits added to the instances applications directory.The instances will then load the application based on the domain.xml. UndeploymentWhen the target instances are offline, the undeployment operations will execute on DAS first. And when the target instances are back up on line, the instances will synchronize with the DAS for the domain.xml and application bits. As part of the synchronization, the relevant application entries will be removed from the instances domain.xml and the applications bits removed from the instances applications directory. Error HandlingDeploymentWhen an application failed to deploy on DAS, we failed the deployment and roll back (if the deployed target is not DAS, the code will not reach the instances as DAS part runs first). The stop, unload, clean will be invoked on DAS to rollback the deployment on DAS. When an application failed to load on instances (some of the instances or all the instances), the stop, unload, clean will be invoked on the relevant instances to rollback the loading. However, we don't fail and rollback the overall deployment, no rollback is done for DAS part of the deployment which has already completed before reaching the instances. We will inform the user the application has failed to load on instanceXXX and advise them to fix their application and redeploy. |