tags:

views:

730

answers:

4

OSGi 4.2 has just been released which updates the 4.1 specification with a few new RFCs. So, what's particularly new with OSGi 4.2, which frameworks support 4.2 already (or are close to) and why should you target new developments against a 4.2 framework instead of a 4.1?

A: 

This article details the RFCs of interest. To quote,

First of all one has to notice that this is not a minor release as the version number may suggest. Release 4.2 is actually way more significant than the R4.1 release last year. At some points I would even say it is more important than the R4 release, because with that one usage becomes way more easier, especially for none OSGi experts.

Brian Agnew
I agree, though some of the RFCs (like the enterprise ones) are not yet complete.
AlBlue
A: 

The early changes were highlighted here.

In particular, the RFC 119 - Distributed OSGi feature is interesting:

This solution defines a minimal level of feature/function for distributed OSGi processing, including service discovery and access to and from external environments.

That combined with EventAdmin (introduced in 41), will allow for easier implementations of OSGi-based distributed services (currently implemented with ECF)

VonC
Yeah, Remote Services (as Distributed OSGi is now called) is interesting. there's a good write up at http://wiki.eclipse.org/Getting_Started_with_Using_the_ECF_Remote_Services_API on how to generally use the remote services with ECF for any of your own ones -
AlBlue
+9  A: 

In most cases, a point release of OSGi (such as 4.1->4.2) doesn't really change much existing behaviour, so it's safe to say that if you have an app that depends on 4.1, it'll run on 4.2 without problem. What is new is that a few items have been standardised which should enable for better interoperability between different OSGi engines (like Equinox, Felix and Knopflerfish).

In fact, although OSGi 4.2 was only released officially on 16th September 2009, early drafts have been available for others to refer to, so previous releases of the products (like Equinox 3.5, Felix 1.8) already have a reasonable support for the standard. Like 802.11n products, they conformed to earlier drafts but the expectation is that they'll be certified as fully compliant against the 4.2 release in the not too distant future.

So, what's new in 4.2?

  • Service Hooks
  • Framework Launching

And, in the compendium

  • Remote Services
  • Bundle Tracker
  • Blueprint Service

Service Hooks

The Service Hook API allows you to pick up on events that occur at the service layer. For example, you can hook into when a service is requested, when a service has an event delivered, and so on. You can also cause events to be not delivered (for example, hiding events that you're not authorised to see) but can't change any events (as this would complicate the classes being delivered). Service hooks are part of the core specification, so all OSGi releases will need this to be compliant.

Framework launching

Although it's possible to programmatically start an OSGi instance from an existing Java application, the way in which you do this has been dependent on which OSGi runtime you're using. In particular, configuration items (such as where to store transient data, what the bundle boot delegation policy should be and so on) were all defined in an engine-specific manner. This consolidates the properties that get set on the framework by any launching utility.

Remote Services

The Remote Services API allows OGSi services to communicate between VMs (possibly on different machines). The exact mechanism of how they communicate (RMI, WebServices etc.) is open to providers, so it's unlike other distributed technologies (like Corba) which specifically dictate an on the wire format. Clearly, distributed services have different semantics than local ones (communication errors, serialisation issues) and it is left to the individual services to be distributable if needed.

Bundle Tracker

Like the ServiceTracker before it in 4.1, the BundleTracker can be used to keep an eye on which bundles come and go in the system. This can be used by dynamic GUIs to show the evolving state of the OSGi engine without any platform specific knowledge.

Blueprint Service

The blueprint service is similar to Spring as it provides a dependency injection mechanism for configuring bundles. In some regards, it is similar to declarative services; but the blueprint service does things in a different manner. In addition, unlike declarative services (which can only deal with services which are present), the blueprint service can create a proxy placeholder in advance for a service which will come on-line later. Calls to the service proxy will then block until the service can be filled (rather than returning 'null' as declarative services will do). If you are comfortable or familiar with Spring IOC and similar dependency injection, then the Blueprint service will be immediately understandable.

AlBlue
Good summary. +1
VonC
NB This isn't necessarily a complete list, and doesn't cover some of the changes to existing services ...
AlBlue
A: 

Do declarative services actually return null when a reference bind is not available? On Equinox, even if I set the mode to dynamic, my component is never instanciated if it can't be "wired". I'd rather prefer it to set to "null" as you say, so that I could have optional reference binds and use dynamic discovery...

Also, I miss the possibility of finding the component properties easily when a service is bound (I have to go to the Bundle context, get service references, iterate and compare -- not practical). Maybe I'm missing something though.

Simon
You can set the cardinality="0..1" or "0..n" in the declarative spec, in which case it's optional and therefore the component may be started even if a dependent service is not available.
AlBlue
Oh, thanks, that's so obvious I missed it ! :)
Simon