Provision bundles from Apache Karaf (ServiceMix) features

Provision bundles from Apache Karaf (ServiceMix) features

Apache ServiceMix 4 Kernel introduced a new functionality related to provisioning of features. As ServiceMix Kernel is about to become an Apache Felix subproject which will may increase the usage of ServiceMix Kernel features files.

To provision bundles from ServiceMix features files you will have to use scan-features provisioning specs:

scan-features:<repository file url>!/<features>

where repository file url is any url supported by standard Java or Pax URL and it must refer to a file that is compliant to the ServiceMix repository file format.

The features is a comma separated list of features names of features available in the file specified by url. The feature name can be only a feature name (e.g. nmr) or a feature name followed by a version (e.g. nmr/1.0.0).
In case that the version is specified, the exact version of the feature will be used. When the version is not specified, the latest version available in the features file will be used.

Pax Runner features scanner will fulfill the contract of features files meaning that it will provision the transitive features (features including other features) as well as load features or transitive features from referenced repositories.

Examples of features scanner usage

Here are some examples of hot to use the features scanner with Pax Runner. The examples are based on using a file from Service Mix:

The features repository xml file is a maven artifact of type "features":

pax-run scan-features:mvn:org.apache.servicemix/apache-servicemix/4.0.0/xml/features!/servicemix-file,servicemix-http/1.0.0

The features repository xml file apache-servicemix-4.0.0-features.xml is on the file system in the current directory:

pax-run scan-features:file:apache-servicemix-4.0.0-features.xml!/servicemix-file,servicemix-http/1.0.0

The features repository xml file apache-servicemix-4.0.0-features.xml is on the file system in directory /Users/Somebody:

pax-run scan-features:file:/Users/Somebody/apache-servicemix-4.0.0-features.xml!/servicemix-file,servicemix-http/1.0.0

The features repository xml file is on the web accessible via http:

pax-run scan-features:http://www.foo.org/servicemix!/servicemix-file,servicemix-http/1.0.

In all of the examples above all the bundles specified by servicemix-file and {servicemix-http}} features will be provisioned, including the transitive ones. For feature servicemix-file there is no version specified meaning that the latest one will be used. For feature servicemix-http the specified version 1.0.0 will be used.