tags:

views:

26

answers:

1

I'm using Apache Karaf as an OSGi container. Karaf have url wrapper which can install bundles directly from maven repository

> install mvn:com.farpost.billing/background-service/2.2-SNAPSHOT
Bundle ID: 139

All works just fine. But I want to start several bundles from given source. This make sense if new bundle occasionally broke production service and I want to rollback. With OSGi this is very straightforward

 > list 
 [ 139] [Active     ] [            ] [Started] [   60] Billing background service (2.2-20100811-1232)
 [ 140] [Resolved   ] [            ] [       ] [   60] Billing background service (2.2-20100809-1127)
 > update 140
 > list
 [ 139] [Active     ] [            ] [Started] [   60] Billing background service (2.2-20100811-1232)
 [ 140] [Resolved   ] [            ] [       ] [   60] Billing background service (2.2-20100812-1354)
 > start 140
 > stop 139
 > list
 [ 139] [Resolved   ] [            ] [       ] [   60] Billing background service (2.2-20100811-1232)
 [ 140] [Active     ] [            ] [Started] [   60] Billing background service (2.2-20100812-1354)
 #################
 # suppose we need to rollback here
 #################
 > start 139
 > stop 140

The problem is I can not create several bundles from one source:

> install mvn:com.farpost.billing/background-service/2.2-SNAPSHOT
Bundle ID: 139
> install mvn:com.farpost.billing/background-service/2.2-SNAPSHOT
Bundle ID: 139

Second install call doesn't do anything but returns already existed bundle id. So my question, is there any way to create several bundles from one source url?

A: 

You're running into the problem that you can not install more than one copy of a bundle with the same symbolic name and version.

Even if you could, there are side effects of having two different versions of the same bundle installed in the scenario you describe, because as long as a bundle is installed, it can be used to resolve packages from. In your scenario, that is probably not what you want, since you want to use either one or the other bundle, but not a mix.

In the end I would advise you to install just the bundle you want. If there are issues with it, roll back by uninstalling the faulty bundle and installing the older version. In case you want to automate the installation and update of (sets of) bundles, take a look at Apache ACE, a software provisioning framework for OSGi that will help you automate such scenarios (and manage OSGi systems in general).

Marcel Offermans