Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Update Component configuration for commons-parent-9

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.

Wiki Markup
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.

Wiki Markup
The Felix project has developed athe \[http://felix.apache.org/site/maven-bundle-plugin-bnd.html Maven Pluginmaven-bundle-plugin\] which makes this easier (_version 1.2.0 released Jan '08_). Before that was released a number of components (Pool 1.4, FileUpload 1.2.1 and IO 1.4) were manually configured with OSGi manifest entries.
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
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).

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="30d8fc17b957a3df-b10405b0-4bbb4a53-a0f79ebe-1927b1be5e71b2e2e5027e0e"><ac:plain-text-body><![CDATA[

chain

1.1

 

[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="cf8545bef6f6bf85-6d8e014b-4b084648-86daab9b-20b4756f2fdbf62069cae167"><ac:plain-text-body><![CDATA[

collections

3.2

 

[http://svn.apache.org/repos/asf/felix/trunk/commons/commons-collections/pom.xml Felix Bundle] doesn't import org.apache.commons.collections.* ??

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a08d9cd033ffa5c0-7349bfdf-4db443b4-a3ed875d-be24a64cde576ee737981a2c"><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="d72c39a7c7b839d7-dcd87809-43fd4788-b6d7b233-0b88ba2a9b376e67b14b942f"><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="b4581188c78bbba7-070a8494-40f84af3-80feaf42-f1057635524587ced25c288e"><ac:plain-text-body><![CDATA[

fileupload

1.2

1.2.1 (m2,manual)

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

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

io

1.3.2

1.4 (m2,manual)

 

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="bb05f07ed4549b6c-51f8902a-44244803-84839314-dcf3de772bf4b40a8b50dca8"><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>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e530f86d73bdb572-6dcd8ff8-4c8e4680-89268f7d-984d5eaf7d24c77eba8d218b"><ac:plain-text-body><![CDATA[

lang

2.3

 

Lang 2.4 looks imminent, see [https://issues.apache.org/jira/browse/LANG-402 LANG-402]

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

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="664f405d157c352c-513162b6-413940c3-a0aca221-e01c29c7919e3d292ce0ff15"><ac:plain-text-body><![CDATA[

math

1.1

1.2 (m2,manual)

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 (m1, manual)

 

primitives

1.0

 

 

proxy

No yet released

1.0 (m2, bundle plugin)

 

scxml

0.7

 

 

transaction

1.2

 

 

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="6b2af05227e0deb8-d98c7737-43514c13-a080b11c-f3fce854256db6fca5ba9a67"><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

 

 

...

Wiki Markup
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

Wiki Markup

...

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

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

No Format

    <instructions>

...

N.B version 8 of the commons-parent pom includes configuration for the felix bundle plugin which should be sufficient for most components. To use that a component needs to do the following:

  • use version 9 of commons-parent
  • specify <packaging>bundle</packaging>
  • add a property with the component's name in lower case

Felix's Maven2 Bundle Plugin

To configure the plugin, specify a

No Format
 <packaging>bundle</packaging> 

element in the pom and configure the plugin in the

No Format
 <build> 

section, for example for Commons Lang

No Format

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>1.2.0</version>
        <extensions>true</extensions>
        <configuration>
          <excludeDependencies>true</excludeDependencies>
          <instructions>
            <Bundle-SymbolicName>org.apache.commons.lang</Bundle-SymbolicName>
            <Export-Package>*;version=${pom.version}</Export-Package>
          </instructions>
        </configuration>
      </plugin>

Notes:

  • <extensions>true</extensions> needs to be specified otherwise the
    No Format
     <packaging>bundle</packaging> 
    is not recognized and causes an error with the message Cannot find lifecycle mapping for packaging 'bundle*_
  • <excludeDependencies>true</excludeDependencies> prevents all the component's dependencies classes being included in the jar
  • Other_* Manifest_* entries are inherited from the commons-parent pom
  • 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.

Configuring via the jar plugin

No Format

      <plugin>
        <artifactId>maven<!-jar-plugin</artifactId>
 stops the "uses" clauses being added  <configuration>
          <archive>to "Export-Package" manifest entry -->
            <manifestEntries>
   <_nouses>true</_nouses>
           <Bundle-SymbolicName>orgSymbolicName>${commons.apache.commons.lang<osgi.symbolicName}</Bundle-SymbolicName>
              <Bundle-License>http://www.apache.org/licenses/LICENSE-2.0.txt</Bundle-License><Export-Package>${commons.osgi.export}</Export-Package>
              <Bundle-ManifestVersion>2</Bundle-ManifestVersion><Private-Package>${commons.osgi.private}</Private-Package>
              <Bundle-Name>Apache Commons Lang Bundle</Bundle-Name><Import-Package>${commons.osgi.import}</Import-Package>
              <Bundle-Vendor>${project.organization.name<DynamicImport-Package>${commons.osgi.dynamicImport}</BundleDynamicImport-Vendor>Package>
              <Bundle-Version>$DocURL>${project.versionurl}</Bundle-Version>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:

No Format

    <properties>
        <Export-Package>
org.apache.commons.lang;version=${project.version},
org<commons.osgi.symbolicName>org.apache.commons.lang.builder;version=${project.version},
org.apache.commons.lang.enum;version=${project.version},
org.apache.commons.lang.enums;version=${project.version},
org.apache.commons.lang.exception;version=${project.version},
org.apache.commons.lang.mathcommons.componentid}</commons.osgi.symbolicName>
        <commons.osgi.export>org.apache.commons.*;version=${projectpom.version},
org.apache.</commons.lang.mutable;version=${project.version},
org.apache.commons.lang.text;version=${project.version},
org.apache.commons.lang.time;version=${project.version}osgi.export>
              </Export-Package><commons.osgi.import>*</commons.osgi.import>
        <commons.osgi.dynamicImport></commons.osgi.dynamicImport>
      <Import-Package>
org.apache.commons.lang;version=${project.version},
org.apache.commons.lang.builder;version=${project.version},
org.apache.commons.lang.enum;version=${project.version},
org.apache.commons.lang.enums;version=${project.version},
org.apache.commons.lang.exception;version=${project.version},
org.apache.commons.lang.math;version=${project.version},
org.apache.commons.lang.mutable;version=${project.version},
org.apache.commons.lang.text;version=${project.version},
org.apache.commons.lang.time;version=${project.version}
              </Import-Package>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>

*Notes:_'

...

  <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 specifing <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

...

.