|
| 1 | +# README |
| 2 | + |
| 3 | +This bundle plugin is an example of how to add dotcms Content Type |
| 4 | + |
| 5 | +## How to build this example |
| 6 | + |
| 7 | +To build the JAR, run the following Maven command: |
| 8 | +```sh |
| 9 | +mvn clean install |
| 10 | +``` |
| 11 | + |
| 12 | +This will generate the plugin JAR in the `target` directory. |
| 13 | + |
| 14 | +## How to install this bundle |
| 15 | + |
| 16 | +* **To install this bundle:** |
| 17 | + |
| 18 | + Copy the bundle JAR file inside the Felix OSGI container (`dotCMS/felix/load`). |
| 19 | + |
| 20 | + OR |
| 21 | + |
| 22 | + Upload the bundle JAR file using the dotCMS UI (`CMS Admin -> Plugins -> Upload Plugin`). |
| 23 | + |
| 24 | +* **To uninstall this bundle:** |
| 25 | + |
| 26 | + Remove the bundle JAR file from the Felix OSGI container (`dotCMS/felix/load`). |
| 27 | + |
| 28 | + OR |
| 29 | + |
| 30 | + Undeploy the bundle JAR using the dotCMS UI (`CMS Admin -> Plugins -> Undeploy`). |
| 31 | + |
| 32 | +## How to create a Actionlet OSGi plugin |
| 33 | + |
| 34 | +In order to create this OSGI plugin, Maven is configured to generate the `META-INF/MANIFEST.MF` file automatically. If needed, you can customize the configuration in the `pom.xml`. |
| 35 | + |
| 36 | +Below is a description of the required fields in the `MANIFEST.MF` and how they are configured in a `pom.xml`: |
| 37 | + |
| 38 | +> **Bundle-Name:** The name of your bundle |
| 39 | +> **Bundle-SymbolicName:** A short and unique name for the bundle |
| 40 | +> **Bundle-Vendor:** The vendor of the bundle (example: dotCMS) |
| 41 | +> **Bundle-Description:** A brief description of the bundle |
| 42 | +> **Bundle-DocURL:** URL for the bundle documentation |
| 43 | +> **Bundle-Activator:** Package and name of your Activator class (example: com.dotmarketing.osgi.actionlet.Activator) |
| 44 | +> **Export-Package:** Declares the packages that are visible outside the plugin. Any package not declared here has visibility only within the bundle. |
| 45 | +> **Import-Package:** This is a comma-separated list of the names of packages to import. This list must include the packages that you are using inside your OSGI bundle plugin and are exported and exposed by the dotCMS runtime. |
| 46 | +
|
| 47 | +These fields are configured in the `pom.xml` as follows: |
| 48 | + |
| 49 | +```xml |
| 50 | +<plugin> |
| 51 | + <groupId>org.apache.felix</groupId> |
| 52 | + <artifactId>maven-bundle-plugin</artifactId> |
| 53 | + <version>5.1.9</version> |
| 54 | + <extensions>true</extensions> |
| 55 | + <configuration> |
| 56 | + <instructions> |
| 57 | + <Bundle-Name>Your Bundle Name</Bundle-Name> |
| 58 | + <Bundle-SymbolicName>com.example.yourbundle</Bundle-SymbolicName> |
| 59 | + <Bundle-Vendor>dotCMS</Bundle-Vendor> |
| 60 | + <Bundle-Description>dotCMS - OSGI Actionlet example</Bundle-Description> |
| 61 | + <Bundle-DocURL>https://dotcms.com/</Bundle-DocURL> |
| 62 | + <Bundle-Activator>com.dotmarketing.osgi.actionlet.Activator</Bundle-Activator> |
| 63 | + <Export-Package>com.example.yourbundle.package</Export-Package> |
| 64 | + <Import-Package>*</Import-Package> |
| 65 | + </instructions> |
| 66 | + </configuration> |
| 67 | +</plugin> |
| 68 | +``` |
| 69 | + |
| 70 | +## Beware (!) |
| 71 | + |
| 72 | +In order to work inside the Apache Felix OSGI runtime, the import and export directives must be bidirectional: |
| 73 | + |
| 74 | +* **Exported Packages** |
| 75 | + |
| 76 | + The dotCMS must declare the set of packages that will be available to the OSGI plugins by updating the file: `dotCMS/WEB-INF/felix/osgi-extra.conf`. |
| 77 | + This can also be configured using the dotCMS UI (`CMS Admin -> Plugins -> Exported Packages`). |
| 78 | + |
| 79 | + Only after the exported packages are defined in this list, can a plugin import the packages to use them inside the OSGI bundle. |
| 80 | + |
| 81 | +* **Fragment (Deprecated)** |
| 82 | + |
| 83 | + Previously, a bundle fragment was used to make its contents available to other bundles by exporting 3rd party libraries from dotCMS. Fragments do not participate in the lifecycle of the bundle and therefore cannot have a Bundle-Activator. As this is no longer required, this section is deprecated. |
| 84 | + |
| 85 | +--- |
| 86 | +## Components |
| 87 | + |
| 88 | +### com.dotmarketing.osgi.actionlet.MyActionlet |
| 89 | + |
| 90 | +Implementation of a WorkFlowActionlet object. |
| 91 | + |
| 92 | +### Activator |
| 93 | + |
| 94 | +This bundle activator extends from com.dotmarketing.osgi.GenericBundleActivator and implements BundleActivator.start(). |
| 95 | +This activator will allow you to register the Content Type object using the GenericBundleActivator.registerActionlet method |
0 commit comments