2 October 2013

Automate p2 Eclipse plugin transfer to Maven

In my last post i discribed a way to transfer Eclsipe p2 plugins to a Maven repository. To automate this in a Maven project one can setup a pom like this:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">



After the transfer the maven bundle plugin will do an indexing so all plugins are also available in the Object Bundle Repository.

29 September 2013

Using Eclipse plugins in a Equinox - Karaf setup.

Using a modular standard like OSGi promises manny goodies, even the ability the swap out the core implementing the OSGi model and deploying bundles on different OSGi implementations ... but not quite. Every implementation brings in its own background like provisioning, restricting things even more. But now i am getting ahead of myself, back to the beginning.

My main OSGi (development) platform so far is Felix wrapped in a Karaf container backed by Maven for provisioning. Now i had to implement the Open Health Tools Model-Driven Health Tools (MDHT) which, as i was about to find out, is Eclipse based and thus uses the provisioning system called p2.

My first thought was to retrieve all the MDHT sources and convert them to Maven projects, there was even a standalone setup provided which proved functional. Looking into the source i discovered MDHT makes heavy use of the Eclipse Modeling Framework (EMF) and the Eclipse Object Constraint Language (OCL), powerful and non trivial frameworks with a lot of dependencies of their own that are mostly not even Mavenized. The deployment on my favorite OSGi combo was bound to fail, i needed an environment matching that of Eclipse.

Then i remembered that Karaf could swap out Felix, and guess for what: Equinox! Simply edit the etc/config.properties file and modify the karaf.framework property to equinox and finished. This leaves me with the provisioning problem since Karaf has a preference for Maven. Converting the sources myself for such big frameworks is not an option for obvious reasons and after some digging i found myself looking at the Maven website: http://maven.apache.org/plugins/maven-eclipse-plugin/.
MDHT is also a modeling tool for Clinical Document Architecture (CDA) templates based on Eclipse, and thus Equinox, meaning it exists out of Eclipse plugins provisioned by p2.
Using the Maven Eclipse Plugin goal eclipse:to-maven i was able to copy the MDHT Eclipse artifacts out of p2 to my local Maven repository and after a re-indexing by the OSGi Bundle Repository (OBR) i finally could install EMF and OCL on my Equinox - Karaf combo. And of course one can now use the Eclipse artifacts in any Maven project.

More practical experiences are bound to follow.

10 July 2013

Monitoring OSGi services and bundles

Keeping track of OSGi services and bundles can be a tedious task. Declerative Services provide a good degree of control here, but for fine grain control the OSGi api presents the org.osgi.util.tracker package.
With the ServiceTracker and BundleTracker classes it is really easy to monitor your enviroment for add, modify or remove events. It provides filtering capabillities trough the customizer interfaces and keeps a record of all registred objects being tracked.
This is also the perfect location to hook into these events, like for updating any logging to be done on the bundles or services in your framework.
The bruise to be avoided here is the addingService / Bundle methodes. These normally return the object that raised the event for the add methode. However, this can be overridden in a subclass to customize the object to be tracked for the one just being added!

26 June 2013

Fuse IDE JMX Explorer not enlisting running jvm's

This is a nice bruise that took me some time to solve. After installing a new jdk and switching Fuse IDE 6.0  to the new installed JRE under Preferences / Java / Installed JRE's, one has to remember that there is a setting under Fuse Plugins for Eclipse / JMX Explorer / Tools that has to be set aswell so the processes to be monitored are running on the same VM as the IDE.
Otherwise no JMX servers get enlisted.