You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 25 Next »

Commons OSGi

The purpose of this page is to record progress in Commons of OSGi-enabled releases and any notes on specific issues with configuration of the OSGi manifest entries.

The [http://felix.apache.org/ Apache Felix] project (an OSGi implementation) have [http://commons.markmail.org/message/36xoo2bo5aabvy5c requested] that Commons components include [http://www.osgi.org/ OSGi] meta data in their jars so that they are ready-to-use in an OSGi environment. This involves OSGi entries in the jar's manifest file.

The Felix project has developed the [http://felix.apache.org/site/maven-bundle-plugin-bnd.html maven-bundle-plugin] which makes this easier and this is now configured in the commons-parent [http://svn.apache.org/repos/asf/commons/proper/commons-parent/trunk/pom.xml pom.xml] (since version 9) with default instructions. For components which need to override the default instructions, this can be done using properties in the component pom (see below for more details).

SpringSource Bundle Repository

The [http://www.springsource.com/repository/app/faq SpringSource Enterprise Bundle Repository] contains a collection of open source libraries and each jar file in the repository is a valid OSGi bundle. This includes a number of [http://www.springsource.com/repository/app/search?query=Apache+Commons&includeLibraries=true&_includeLibraries=on&includeBundles=true&_includeBundles=on re-packaged Commons components], so if you require a component that has not yet been released as an OSGi bundle, you may find it in the SpringSource repository.

N.B. As of writing (May 2008) the status of SpringSource repository is [http://www.springsource.com/repository/app/faq#q2 BETA].

Proper

Component

Last Release

First OSGi release

Notes / Comments

attributes

2.2

 

No m2 build

beanutils

1.8.0-BETA

 

 

betwixt

0.8

 

 

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8c11cab4-c6ca-4486-ab93-0aaf7fc4d9e9"><ac:plain-text-body><![CDATA[

chain

1.1

1.2

[http://felix.markmail.org/message/tgm45au3rpmpmfnf javax.portlet]

]]></ac:plain-text-body></ac:structured-macro>

cli

1.1

 

 

codec

1.3

 

 

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d290324f-a634-44c8-8303-77b0684902e7"><ac:plain-text-body><![CDATA[

collections

3.2

3.2.1

[http://svn.apache.org/repos/asf/felix/trunk/commons/commons-collections/pom.xml Felix Bundle] doesn't import org.apache.commons.collections.* - asked on [http://felix.markmail.org/message/paqqbwyfcfhxz22f dev@felix]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="cf255e97-609d-40b5-a0fc-256cc7b28aa1"><ac:plain-text-body><![CDATA[

configuration

1.5

 

[http://svn.apache.org/repos/asf/felix/trunk/commons/commons-configuration/pom.xml Felix Bundle] uses alot of dynamic import

]]></ac:plain-text-body></ac:structured-macro>

daemon

1.0.1

 

 

dbcp

1.2.2

 

 

dbutils

1.1

 

 

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="38631ad1-a541-4bfe-a9a4-51fb1eebbddd"><ac:plain-text-body><![CDATA[

digester

1.8

 

[http://svn.apache.org/repos/asf/felix/trunk/commons/commons-digester/pom.xml Felix Bundle] does dynamic import of org.apache.commons.logging.impl

]]></ac:plain-text-body></ac:structured-macro>

discovery

0.4

 

 

el

1.0

 

 

email

1.1

 

 

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="93dc60e3-a0d5-4895-a8e2-7131e21f4ba4"><ac:plain-text-body><![CDATA[

fileupload

1.2

1.2.1

[http://felix.markmail.org/message/tgm45au3rpmpmfnf javax.portlet]

]]></ac:plain-text-body></ac:structured-macro>

io

1.3.2

1.4

 

jci

1.0

 

 

jelly

1.0

 

No m2 build

jexl

1.1

 

 

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="775511bf-80de-40a0-a91f-47492c24d196"><ac:plain-text-body><![CDATA[

jxpath

1.2

 

See [http://svn.apache.org/repos/asf/felix/trunk/commons/commons-jxpath/pom.xml Felix Bundle]

]]></ac:plain-text-body></ac:structured-macro>

lang

2.3

2.4

 

launcher

1.1

 

 

logging

1.1.1

 

OSGi is N/A; See Below

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="615ad458-6c66-4ab9-88a1-853295fabd16"><ac:plain-text-body><![CDATA[

math

1.1

1.2

See [https://issues.apache.org/jira/browse/MATH-180 MATH-180]

]]></ac:plain-text-body></ac:structured-macro>

modeler

2.0.1

 

 

net

1.4.1

 

 

pool

1.3

1.4

 

primitives

1.0

 

 

proxy

n/a

1.0

 

scxml

0.7

0.8

 

transaction

1.2

 

 

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d1357a4c-ecea-4ce9-b91b-4c81e61c3bdd"><ac:plain-text-body><![CDATA[

validator

1.3.1

 

[http://svn.apache.org/repos/asf/felix/trunk/commons/commons-validator/pom.xml Felix Bundle] has org.apache.oro.*;resolution:=optional

]]></ac:plain-text-body></ac:structured-macro>

vfs

1.0

 

 

Commons Logging

The things that commons-logging does with classloaders in order to try and work in various servlet engine configurations are not compatible with the classloaders that OSGi environments set up. Therefore adding OSGi attributes to commons-logging is not useful, as commons-logging is not usable in an OSGi environment. See [http://commons.markmail.org/message/kdnjlbokvuiigcew this thread] and
[http://wiki.ops4j.org/dokuwiki/doku.php?id=pax:logging Pax-logging]

Having said that the Felix project has a bundle to re-package logging - see [http://svn.apache.org/repos/asf/felix/trunk/commons/commons-logging/pom.xml here]

Configuring Commons Components for OSGi with Maven1

This can be done by specifying appropriate manifest entries for the jar plugin (Pool 1.4 is an [http://svn.apache.org/repos/asf/commons/proper/pool/tags/POOL_1_4/project.properties example]) - however it is much easier using maven2 and the maven-bundle-plugin.

Configuring Commons Components for OSGi with Maven2

The latest version of the [http://svn.apache.org/repos/asf/commons/proper/commons-parent/trunk/pom.xml commons-parent pom] configures the
[http://felix.apache.org/site/maven-bundle-plugin-bnd.html maven-bundle-plugin]'s instructions using properties in the following way:

    <instructions>
        <!-- stops the "uses" clauses being added to "Export-Package" manifest entry -->
        <_nouses>true</_nouses>
        <Bundle-SymbolicName>${commons.osgi.symbolicName}</Bundle-SymbolicName>
        <Export-Package>${commons.osgi.export}</Export-Package>
        <Private-Package>${commons.osgi.private}</Private-Package>
        <Import-Package>${commons.osgi.import}</Import-Package>
        <DynamicImport-Package>${commons.osgi.dynamicImport}</DynamicImport-Package>
        <Bundle-DocURL>${project.url}</Bundle-DocURL>
    </instructions>

This allows component poms to easily override the default values, by specifying alternative values for these properties in their pom. The default values for these properties in commons-parent are:

    <properties>
        <commons.osgi.symbolicName>org.apache.commons.${commons.componentid}</commons.osgi.symbolicName>
        <commons.osgi.export>org.apache.commons.*;version=${pom.version}</commons.osgi.export>
        <commons.osgi.import>*</commons.osgi.import>
        <commons.osgi.dynamicImport></commons.osgi.dynamicImport>
        <commons.osgi.private></commons.osgi.private>
    </properties>

For example, depending on the nature/structure of the project, some packages might contain private classes that are not meant to be used by client code. In these cases, <Export-Package> should list all public packages while <Private-Package> should contain the private packages. This can be achieved by overriding the <commons.osgi.export> and <commons.osgi.private> properties in the component pom.

Version 8 of commons-parent required specifying <packaging>bundle</packaging> in the component pom - with version 9 this is no longer required. In version 9, the maven-bundle-plugin is configured to generate a MANIFEST.MF file containing the OSGi meta data in the target/osgi folder. The maven-jar-plugin is configured to merge this generated MANIFEST.MF file with the manifest entries it is configured with. If a component does not want to include OSGi meta-data in their pom's manifest file they can configure an alternative or blank manifest file location using the <commons.manifestfile> property.

  • No labels