Tuesday, January 13

Guice-Peaberry vs Spring-DM

six times as fast, half the size!

Of course it's never that simple, these are just some fun measurements I took today using a trivial testcase that injects an OSGi service. They completely ignore functionality, flexibility, usability, and many other *bilities... flame-on!

Wednesday, January 7

Happy new year!

Just completed one of my new year resolutions and uploaded a release candidate of peaberry. See my message on the Guice-OSGi group for a few more details.

OK onto my next resolution, back to writing more chapters for OSGi in Action...

Thursday, December 18

Want to hear the latest on Guice and OSGi?

Then you'll want to attend EclipseCon 2009, where you can hear me talk about using Guice and the peaberry extension to blend OSGi services with Eclipse extensions:

http://www.eclipsecon.org/2009/sessions?id=315

I'll also be running through some of the design decisions behind peaberry which I think are pretty neat - like the recent work on "outjection" that lets you share services between registries and watch for service updates. If I have time I'll also discuss some thoughts about lifecycle support (for some background see Todor's recent request).

I'm going to be around for the whole conference, so you'll have plenty of opportunities to ask me questions about peaberry, Pax-Construct, the maven-bundle-plugin, or the "OSGi in Action" book :)

Tuesday, December 9

How much OSGi should I use?

This began as a quick reply to a question on the Felix users list about bundling third-party libraries, but these days once I start writing I find it hard to stop! Hope you find it useful...
It's actually up to you - OSGi doesn't force you to make everything a bundle, it merely helps you when you decide to modularize.

So if you want to put third-party libraries on your application classpath and use the "org.osgi.framework.bootdelegation" property to make them visible to all bundles then you can. You could then concentrate on modularizing your application without worrying about legacy classloading issues - however it would also mean you couldn't replace these libraries at runtime, or have multiple versions of them loaded at the same time. Additionally, if you use tools to generate OSGi manifests you'd need to tell them that these packages should not be marked as imported, as they're available instead using bootdelegation - otherwise your bundles would have trouble resolving, because no other bundle would be exporting these packages.

Or you could keep the libraries on your application classpath and use "org.osgi.framework.system.packages.extra" to augment the exports from the main system bundle. Unlike bootdelegation, your bundles would need to import any of these packages they want to use - and these imports would then get wired to the system bundle. However, because you're now using OSGi resolution to find these packages you could replace them at runtime and have other bundles provide alternative versions. The downside is that you may find issues with a few legacy libraries that expect the "classic" model (ie. everything on the application classpath)

Later on you might decide to move libraries from the application classpath into one or more OSGi bundles - you could either crack open the library and add OSGi metadata to the manifest to export everything, or use a tool like BND to create a new jar based on the original. This is great if you want to share libraries between bundles - but if the library is only used by one bundle then it might make more sense to embed the library inside that bundle, especially if it's an implementation detail and you never expect to export any packages. Again you have a choice: you can unpack the library inside your bundle, or embed the jar as-is and add it to your Bundle-ClassPath (OSGi supports "jars within jars").

Once you have the third-party library as (or inside) an OSGi bundle then you can start thinking about making certain packages private, and add a Bundle-Activator to initialize and clean up resources and/or threads. Using an activator is optional and while it will introduce a compile time dependency to OSGi, it doesn't force the library to use OSGi at runtime. You can still use the library in classic Java applications, because they won't attempt to load the activator class. This is cool, because it means you can fully participate in the OSGi lifecycle without affecting anyone not interested in OSGi.

The best part is that you can mix any of these approaches in your application and you can decide when move between them. You're not forced to make everything a bundle, and you may even decide to move bundles back to the application classpath. Feel free to use as much or as little of OSGi as you like :)

Thursday, December 4

Wednesday, November 26

OSGi (Services) in Action

Just noticed that my chapter on OSGi services has reached the Manning Early Access Program. Hope you enjoy reading it, and remember to post any comments or questions on our author forum.

Here's some of the topics covered in Studying Services:
  • The what, why and when of services

  • OSGi services in action!

  • Dealing with dynamics

  • Using services in the paint example

  • How services relate to modularity and lifecycle

  • Framework services

Monday, November 17

Do you remember to unget OSGi services?

Just posted the first set of code examples for OSGi in Action, chapters 1 to 4:

   http://code.google.com/p/osgi-in-action/

The answer to when you should "unget" an OSGi service (and why you should bother) will be explained in chapter 4 of the book, which will hopefully reach Manning's Early Access Program very soon.

Spoiler alert: take a peek at chapter04/dynamics.

Friday, October 24

OSGi in Action!

The kind folks at Manning have just made the first chapter of "OSGi in Action" available through their early access program: http://manning.com/hall/

Unfortunately the figures seem to be chopped off in the PDF, so apologies for that in advance... we're using OpenOffice to write the book and this is apparently new for Manning, so there's still a couple of bugs to squash in the publishing process. Never mind, the next update will be much better!

Richard, Karl and I are eagerly working on getting the next few chapters ready for MEAP. This is where we delve into the different layers of OSGi (modularity, lifecycle and services) with plenty of examples to explain the differences and best practices.

Those of you signed up to MEAP can send comments and corrections via the author forum. You can also reach us via the usual lists (Felix, OPS4J, etc.)

That's all for now - got to get back to writing!