Build your launcher
Principle
A Stanbol launcher is a big set of bundles that work together and provide features packages (EntityHub, ContentHub, Enhancer,...). Each features package need a list of bundles to work smoothly.
Thanks for Stanbol design, you can have in your server only some of the proposed features package (for example only the EntityHub and Enhancer, without others features). Then you only need required bundles for the features package you want.
But identify and manually add all feature's required bundles can be pain and long. Hopefully, the bundlelist mechanism allow the creation of specific set of bundles that will be added together to the launcher and started in the right way.
Stanbol launcher's use this bundlelist mechanism. Let's dive into the details.
Use existing bundlelists to build your launcher
Dependencies to bundlelist
- Bundlelist are in fact just jar. So you just need to declare them as dependencies in you launcher pom.xml to get the feature package and all required bundle for it.
- For example, if you want the entityHub feature in you server, you only need to add this dependency to your launcher pom.xml :
<dependency>
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.entityhub.bundlelist</artifactId>
<version>0.11.0-SNAPSHOT</version>
<type>partialbundlelist</type>
<scope>provided</scope>
</dependency>
- Please note the
<type>partialbundlelist</type>
property of the dependency. - Also in actual Stanbol code base you can easily detect feature package bundlelist as their artifactId has the structure org.apache.stanbol.{feature-name}.bundlelist
Build your launcher
- Let's imagine that for now you only use EntityHub and Enhancer features packages.
-
The more simple way to get you custom launcher is to :
- copy the full launcher folder to "my-launcher" folder
- open the my-launcher/pom.xml and change the
<artifactId>org.apache.stanbol.launchers.full</artifactId>
node to<artifactId>my.launcher</artifactId>
-
Then you get a custom launcher, but still with all the Stanbol features.
-
To only keep the features you want (EntityHub and Enhancer in this example), scroll down to the
<dependencies>
part and remove all but dependencies labelled with :- "The Apache Stanbol lauchpad" and "maven-launchpad-plugin builds on the launchpad.base app" : dependencies required for the launcher to launch
- "OSGi Framemework Bundle List" : provide all bundle for the OSGI in Stanbol
- "Stanbol Commons Bundle List" : contains all the feature's shared bundles
- "Stanbol Data Bundle List" : keep it only if you plan to use dataset provided by Stanbol in the EntityHub
- "Stanbol Enhancer Bundle List" : will provide all required bundles for the enhancer feature
- "Stanbol Entityhub Bundle List" : will provide the EntityHub feature
-
At the end, your
<dependencies>
section only contains this 7 dependencies. - Do an "mvn clean install"
- Move to you target folder and launch the my-launcher.jar.
- You get a running Stanbol with only the features you need.
Create your own bundlelist
-
Going to the road of Stanbol development and use, you will just not only need to cherry pick Stanbol's features package you want but also provide your own set of bundles directly to the launcher during the building phase.
-
The bundlelist mechanism is the perfect and simple way to include your list of bundles into your launcher !
Build your bundlelist dependency
- Bundlelist (or partialbundlelist) artifact is a really simple Maven project that rely on this structure :
mybundlelistFolder | |- pom.xml |- src |- main |- bundles |- list.xml
- You only need to define 2 files :
- pom.xml : really simple you can copy-paste the Enhancer bundlelist one and only change the groupId and artifactId properties to suit you need. All the magic here is contained in
property. - list.xml : this file will contains information about the bundles you want to include. This file has a simple structure :
- pom.xml : really simple you can copy-paste the Enhancer bundlelist one and only change the groupId and artifactId properties to suit you need. All the magic here is contained in
<bundles>
<startlevel level="L0">
<bundle>
...Maven groupId,artifactID and version properties...
</bundle>
<bundle>
...another Maven's dependency information...
</bundle>
</startlevel>
<startlevel level="L1">
... anothers bundles nodes...
</startlevel>
</bundles>
-
Start level is an important things to keep in mind as the value of the "level" property will determine when your bundle is started during the server launch.
- So, if your bundle require some other services to be up and running, be sure to define a higher start level to your bundle that the ones of the required services.
-
You can find and extensive bundlelist definition for inspiration in the Enhancer bundlelist list.xml.
Add your bundlelist to your launcher
- Let's says that your bundlelist pom.xml contains :
<groupId>com.example</groupId>
<artifactId>my.bundlelist</artifactId>
<version>0.10.0-SNAPSHOT</version>
<packaging>partialbundlelist</packaging>
- Bring your bundles into your launcher only require you to edit my-launcher/pom.xml and add in
section, this one :
<dependency>
<groupId>com.example</groupId>
<artifactId>my.bundlelist</artifactId>
<version>0.10.0-SNAPSHOT</version>
<packaging>partialbundlelist</packaging>
</dependency>
- Stanbol is now all yours !