I've checked with the jetty project, from version 6.1.5 onward they jars
will be OSGi "enabled", and they are using the same maven plugin I talked
about. And Spring-OSGi is also using it, so I think it's a good start :)
The first step is to use the plugin to generate the manifests. I modified
the pom.xml from the rt/core to include:
<packaging>bundle</packaging>
This is the package specifier to create osgi manifests.
- <#> <plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
- <#> <configuration>
- <#> <instructions>
<Private-Package>org.apache.cxf.*</Private-Package>
<Bundle-Version>1.0.0</Bundle-Version>
</instructions>
</configuration>
</plugin>
Here I am telling the plugin that all packages are private to the jar. So
the resulting manifest is:
Manifest-Version: 1
Bundle-Vendor: Apache Software Foundation
Private-Package: META-INF.cxf,META-INF.services,org.apache.cxf,
org.apache.cxf.attachment,
org.apache.cxf.binding,org.apache.cxf.bus,org.apache.cxf.bus.extension,
[...]
Bundle-Version: 1.0.0
Bundle-Name: Apache CXF Runtime Core
Created-By: Bnd-0.0.106
Bundle-ManifestVersion: 2
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Include-Resource: src/main/resources/
Bundle-DocURL: http://www.apache.org/
Bundle-SymbolicName: org.apache.cxf.cxf-rt-core
Import-Package: com.ibm.wsdl.extensions.schema,com.ibm.wsdl.extensions.soap,
javax.activation,javax.annotation,javax.jws,javax.jws.soap,javax.mail,
javax.mail.internet,
javax.management,javax.net.ssl,javax.wsdl,
[...]
The important sessions here are Private-Package, Import-Package and
Export-Package (not seen in this example). In OSGi dependency is specified
in package level, so Import-Package declares the needed packages to import
and is automatically created by the plugin.
The Export-Package lists the packages exported by the jar to other packages.
It's important to understand that the osgi runtime enforces this visibility,
so even if you declare public classes inside a jar they will not be seen to
other jars unless they are exported. The Private-Package is the opposite.
So the first step will be to write this definitions. At first I will export
all packages and see how it works. As I am not a maven guru I would need
some advice which pom.xml put the necessary <repository> and
<pluginRepositories> sections needed by the plugin (probably in the root
pom?).
I would like to point to more detailed references:
Bundle Plugin for Maven:
http://cwiki.apache.org/FELIX/bundle-plugin-for-maven-bnd.html
Bnd tool this plugin is based:
http://www.aqute.biz/Code/Bnd
Sample use of this tool to wrap hibernate as osgi bundle:
http://www.aqute.biz/Code/BndHibernate
Getting Started with OSGi series:
http://neilbartlett.name/blog/osgi-articles<http://neilbartlett.name/blog/osgi-articles/>
Gustavo
On 7/12/07, Oisin Hurley <[EMAIL PROTECTED]> wrote:
> I see that there's a open ticket (
> http://issues.apache.org/jira/browse/CXF-490) for creating OSGi
> bundles. I
> have made a small experiment to include the maven bundle plugin (
> http://cwiki.apache.org/FELIX/maven-bundle-plugin-bnd.html) in the
> runtime
> core jar to gererate osgi compatible manifests. If there is
> interest I could
> give more details and help with this ticket.
Definitely some interest from me, Gustavo, let's have some more
details :)
cheers
--oh
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-core</artifactId>
<packaging>bundle</packaging>
<version>2.1-incubator-SNAPSHOT</version>
<name>Apache CXF Runtime Core</name>
<url>http://cwiki.apache.org/CXF</url>
<parent>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-parent</artifactId>
<version>2.1-incubator-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.ws.commons.schema</groupId>
<artifactId>XmlSchema</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-javamail_1.4_spec</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymockclassextension</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Private-Package>org.apache.cxf.*</Private-Package>
<Bundle-Version>1.0.0</Bundle-Version>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/incubator/cxf/trunk/rt/core</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/cxf/trunk/rt/core</developerConnection>
<url>http://svn.apache.org/viewvc/incubator/cxf/trunk/cxf-parent/cxf-rt-core</url>
</scm>
<repositories>
<repository> <!-- (3) START -->
<id>apache.m2.incubator</id>
<name>Apache M2 Incubator Repository</name>
<url>http://people.apache.org/repo/m2-incubating-repository/</url>
</repository> <!-- (3) END -->
</repositories>
<pluginRepositories>
<pluginRepository> <!-- (4) START -->
<id>apache.m2.incubator</id>
<name>Apache M2 Incubator Repository</name>
<url>http://people.apache.org/repo/m2-incubating-repository/</url>
</pluginRepository> <!-- (4) END -->
</pluginRepositories>
</project>