...
An OSGi bundle can be in one of the following states:
Property | Purpose |
---|---|
Installed | The bundle has been successfully installed. |
Resolved | All Java classes that the bundle needs are available. This state indicates that the bundle is either ready to be started or has stopped. |
Starting | The bundle is being started, the |
Active | The bundle has successfully started and is running. |
Stopping | The bundle is being stopped. The |
Uninstalled | The bundle has been uninstalled. It cannot move into any other state. |
OSGi Bundle Lifecycle
The lifecycle of an OSGi bundle is depicted in the figure below. The lifecycle starts with the installation of the bundle. If all Java classes that the bundle depends on are available, the OSGi bundle proceeds to the resolved state. From there the bundle can be started or uninstalled. When started, the bundle becomes active unless some runtime error occurs during the starting of the bundle. If that happens, the bundle remains resolved. An active bundle can be stopped in which case the bundle proceeds to the resolved state. When a resolved bundle is uninstalled it proceeds to the uninstalled state and stays there.
...
A plugin exists only within the active state of the OSGi bundle, therefore the API that makes an OSGi bundle a plugin can only be accessed during the active state of the OSGi bundle. The API methods of a plugin that affect the lifecycle of the plugin are available on a component bundle, which is only available when the bundle is active. These methods are:
Property | Purpose | ||
---|---|---|---|
Start() | Registers services that each component within the bundle exposes if all required service dependencies are available. For each component, at least a component service is registered. | ||
Stop() | Stops all services registered by the component. | ||
Update() | Updates a plugin to a new version. | ||
Uninstall() | Removes all content that was created during the installation of the component and uninstalls the plugin. | ||
Uninstall(doPurge) | Removes all content that was created during and after the installation of the component and uninstalls the plugin.
| ||
Purge() | The bundle has been uninstalled. It cannot move into any other state. |
The lifecycle of a plugin is depicted below.
...
The plugin lifecycle methods are:
Lifecycle | Purpose | |||||||
---|---|---|---|---|---|---|---|---|
onStart() | Allows a component to attach logic to a start event. For example:
Dependencies:
| |||||||
onInstall() | Allows a component to attach logic to an install event. For example:
Dependencies:
| |||||||
onStop() | Allows a component to attach logic to a stop event. For example:
Dependencies:
| |||||||
onUpdate() | Allows a component to attach logic to an update event. For example:
Dependencies:
| |||||||
onUninstall() | Allows a component to attach logic to an uninstall event. The plugin containing the component must be in an active state in order for the
Dependencies:
| |||||||
onPurge() | Allows a component to attach logic to a purge event.
Dependencies: | |||||||
onInit() | Allows a component to attach logic to an init event. For example:
Dependencies: | |||||||
onDestroy() | Allows a component to attach logic to a destroy event. For example:
Dependencies:
onDestroy() |
...
Plugin Management Console
...
In addition to the functionality available for managing plugins from the XperienCentral Plugins Management Console, there are equivalent commands available in the Apache Felix Gogo shell that you can invoke directly from the command line. To use the commands on a plugin in the Apache Felix Gogo shell, you must determine the ID of a plugin by issuing the ps
command. After you issue the ps
command, you will see a list of the plugins as shown in the figure above.
Command | Purpose | ||
---|---|---|---|
wmstart [id] | Registers services that each component within the bundle exposes if all required service dependencies are available. For each component, at the very least a component service is registered | ||
wmstop | Stops all services registered by the component. | ||
wmupdate | Updates the plugin to a newer version. If a problem is encountered during the update, the plugin is automatically rolled back to the existing version. The following describes a typical plugin update scenario:
| ||
wmpurge | Removes all content that was created during and after the installation of the component. | ||
wmuninstall | Removes all content that was created during the installation of the component.
|
...
Service Dependencies
...
The table below shows an overview on the service injections for each component type.
Component | Service is injected in | Injection type |
---|---|---|
Element |
| Field access |
Element |
| Setter method |
Panel
|
| Field access |
Panel |
| Setter method |
Media item |
| Field access |
Media item |
| Setter method |
Form |
| Field access |
Form |
| Setter method |
Page metadata |
| Field access |
Page metadata |
| Setter method |
Presentation |
| Field access |
Service |
| Field access |
Servlet |
| Field access |
Servlet | HttpServlet | Setter method |
Using service dependencies as described here is a required guideline for level 1 certification, see guideline /wiki/spaces/PD/pages/24721296 of the development guidelines.
...