Thursday, April 26

Guice and OSGi

I recently wrote a patch for Guice, which adds OSGi metadata to the jarfile and fixes some classloader issues when running on OSGi. Just apply this patch to the current Guice trunk (and copy the attached bnd-0.0.130.jar to the lib/build folder) and do "ant clean dist".

You can now take the Guice jar from build/dist and use it in any OSGi framework - there's an example over at OPS4J:

( btw, peaberry is a simple entity framework to test Guice and AOP on OSGi ... it only provides partial entity bean support, hence the name: Peaberry ;)

Tuesday, April 24

OSGi Alliance Community Event

OSGi Alliance Community Event, June 26th-27th Munich, Germany

Should be interesting - I'm thinking of going, as I'll be in Europe for June/July.

Monday, April 23

Quick OSGi projects using Maven archetypes

Have you ever wanted to try OSGi, but found setting up the build and working out the manifest too much of a chore?

If so then help is at hand - over the last few months, I have been developing a set of Maven archetypes and plugins to automate much of the manual work required in creating an OSGi project. Recently I also provided Windows batch files and Linux shell scripts to make it even easier:

All you need is Maven2 and a Java5 runtime - the best part is the OSGi manifest attributes are automatically calculated for you by Peter Krien's wonderful bnd tool, connected to Maven by the maven-bundle-plugin from the Apache Felix project.

For example, the following commands would create a simple skeleton OSGi web application ... and deploy it to Equinox:

pax-create-project -g simple.project -a osgi-web-app

cd osgi-web-app

mvn install

pax-wrap-jar -g javax.servlet -a servlet-api -v 2.5
pax-import-bundle -g org.ops4j.pax.logging -a api -v 0.9.4
pax-import-bundle -g org.ops4j.pax.logging -a jcl -v 0.9.4
pax-import-bundle -g org.ops4j.pax.logging -a slf4j -v 0.9.4
pax-import-bundle -g org.ungoverned.osgi.bundle -a http -v 1.1.2
pax-create-bundle -p my.osgi.code.myBundle -n myBundle

mvn install pax:provision

all you need to add is the internal application code ;)