h1. Introduction
{section}
{column}
Several concurrent life-cycles exist in Petals ESB:
* [the Petals ESB container life-cycle|#petals-esb-lifecycle],
* [the shared-library life-cycle|#sharedlibrary-lifecycle],
* [the component life-cycle|#component-lifecycle],
* [the service-assembly life-cycle|#service-assembly-lifecycle],
* [the service-unit life-cyle|#service-unit-lifecycle].
{column}
{column:width=35%}
{panel:title=Table of contents}{toc:outline=true}{panel}
{panel:title=Contributors}{contributors:order=name|mode=list|showAnonymous=true|showCount=true|showLastTime=true}{panel}
{column}
{section}
{anchor:petals-esb-lifecycle}
h1. The Petals ESB container life-cyle
The Petals ESB container life-cycle is very simple.
{gliffy:name=Petals ESB lifecyle|version=2}
It contains only one state: STARTED. The implicit state 'STOPPED' does not really exist because in such state no Petals ESB process is running.
The transition from state 'STOPPED' to 'STARTED' is realized using the Petals ESB startup script '{{petals-esb}}'. The return to the state 'STOPPED' is realized using {{^C}} or the command '{{petals-esb stop}}'. See [Starting and stopping Petals ESB].
*When stopping a Petals ESB container, _all its components are shutdown_*. When starting the Petals ESB container, shared libraries, components, service assemblies and service units are restored to the state in which they was when stopping the container.
{anchor:sharedlibrary-lifecycle}
h1. The shared-library life-cyle
h2. The life-cycle
The shared-library life-cycle is simple.
{gliffy:name=Shared-Library lifecyle|version=3}
It contains only one state: INSTALLED. The implicit state 'UNINSTALLED' does not really exist because the shared-library is not instantiated or loaded.
The transition from state 'UNINSTALLED' to 'INSTALLED' is realized installing the shared library, and the return to the state 'UNINSTALLED' is realized uninstalling the shared-library. A shared library can be (un)installed using [Petals CLI|petalsesb:Command Line Interface], [the Petals Autoloader|Petals ESB "Autoloader"], Petals Ant Tasks or the JMX API.
{anchor:sharedlibrary-lifecycle-constraints}
h2. Constraints
The shared library life-cycle is linked to the component life-cycle:
* a shared library required by a component must be installed before to load the component
* a shared library can not be uninstalled until a component requiring it is installed.
|| Component state || installSharedLibrary || uninstallSharedLibrary ||
| UNLOADED | !checkOk.png|align=center,width=20px! | !checkOk.png|align=center,width=20px! |
| LOADED/UNINSTALLED | !checkErro.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! |
| INSTALLED/SHUTDOWN | !checkErro.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! |
| STOPPED | !checkErro.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! |
| STARTED | !checkErro.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! |
{anchor:component-lifecycle}
h1. The component life-cycle
h2. The life-cycle
The component life-cycle is the more complex life-cycle of Petals ESB life-cycles. It is composed of two correlated sub life-cycles:
* the component installer life-cycle that drives the installation of the component,
* the component life-cycle itself.
{gliffy:name=Component lifecyle|version=6}
The state {{INITIALIZED}} is a temporary state in the startup transition. The transition {{init}} and {{start}} are automatically enchained when starting a component from the state {{SHUTDOWN}}.
Actions associated to states:
* when initializing the component:
** the endpoints of the [native services|Glossary#Native_Service] are registered,
* when starting the component:
** it will be able to process request messages,
* when stopping the component, no more request message is processed,
** all resources (as database, pools, ...) used by the message processing are released,
* when shutting down the component:
** all resources (as database, pools, ...) used by the service unit (un)deployment on state {{STARTED}} and {{STOPPED}} are released,
** the endpoints of the native services are unregistered.
h2. Constraints
The component life-cycle is linked to:
* [the shared life-cycle|#sharedlibrary-lifecycle-constraints],
* [the service-assembly lifecycle|#serviceassembly-lifecycle-constraints],
* the service-unit life-cycle,
* and have following constraint against the service-unit life-cyle:
|| Service unit state || loadNewInstaller || install || start || stop || shutdown || uninstall || unloadInstaller ||
| UNDEPLOYED | !checkOk.png|align=center,width=20px! | !checkOk.png|align=center,width=20px! | !checkOk.png|align=center,width=20px! | !checkOk.png|align=center,width=20px! | !checkOk.png|align=center,width=20px! | !checkOk.png|align=center,width=20px! | !checkOk.png|align=center,width=20px! |
| SHUTDOWN | !checkErro.png|align=center,width=20px!| !checkErro.png|align=center,width=20px! | !checkOk.png|align=center,width=20px! | !checkOk.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! |
| STOPPED | !checkErro.png|align=center,width=20px!| !checkErro.png|align=center,width=20px! | !checkOk.png|align=center,width=20px! | !checkOk.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! |
| STARTED | !checkErro.png|align=center,width=20px!| !checkErro.png|align=center,width=20px!| !checkOk.png|align=center,width=20px! | !checkOk.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! | !checkErro.png|align=center,width=20px! |