Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSGi Bundle Repositories (How to host them on a Server)?

Tags:

osgi

I would like to ship a product that is merely a configured OSGi container. When the container is launched it should, based on the configuration of the container, download and install the application - the most recent bundle(s) which comprise all the functionality of the application. When a newer version of the application becomes available I would like the application to automatically download and update/install the newer versions of the bundles so it appears seamless to the end user.

Based on the Motivation section of the Apache Felix OSGi Bundle Repository documentation (which is currently outdated) I think this is the purpose of OBR. Is that correct?

If not then what solutions exist for this scenario?

If so:

  1. What does an OBR repository look like? I envision it to look somewhat like a maven repository that is accessible via the Internet with an XML file that describes the available bundles in the repository.

  2. How does one manage a repository that can be accessed from the Internet?

The aforementioned documentation states that:

An OBR "repository server" is not necessary, since all functionality may reside on the client side.

But I assume that there does exist some "OBR repository server" for those repositories that should be accessible from the Internet. In this example situation, I would rather that the repository does not sit on the client side, but on a server so clients can be easily updated. To accomplish this, would I just set up an HTTP server that hosts 1) some xml file that describes the bundles available in the repository, and 2) the bundles?

Lastly, is there a simple example somewhere that demonstrates how all this works together?

like image 482
axiopisty Avatar asked Dec 02 '13 21:12

axiopisty


2 Answers

Your understanding is exactly right. The main thing to watch out for when using OBR is that the XML format changed a lot when the soecification was finalised. Sometimes 'OBR support' means the old style, and sometimes the new style. As long as client and server are consistent, either should be fine. The new format is richer, but at the moment there's wider support for the old style.

To set up your own http hosting, you can use repoindex (formerly known as bindex). Apache Aries also has a repository generation tool.

Using the 'index' goal with the maven bundle plugin will generate OBR metadata, and bnd can also be directly configured to generate the repository.xml.

Finally, if you don't want to manage the http server directly, Nexus and Karaf Cave provide OBR repository hosting.

You may also find this question helpful: OSGI OBR repository hosting?

like image 125
Holly Cummins Avatar answered Oct 24 '22 13:10

Holly Cummins


This is how I did it once for one of my projects, that compiles with Maven.

What you need :

  • a Maven repository (such as Sonatype Nexus) to deploy the jar files

  • a ftp or a webDAV server to upload the repository.xml file (Nexus Pro can do this, but you have to pay...)

In my POM file, I added the following

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.3.7</version>
        <extensions>true</extensions>
        <executions>
            <execution>
                <goals>
                    <goal>deploy</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <remoteOBR>repository.xml</remoteOBR>
            <altDeploymentRepository>my.obr.name::default::ftp://obr.example.com</altDeploymentRepository>
            <prefixUrl>http://my.maven.repository.com/content/groups/public</prefixUrl>
            <ignoreLock />
        </configuration>
</plugin>

When you execute the mvn deploy command, this will update the ftp://obr.example.com/repository.xml file that will link to the jars on your repository (thus the prefixURL tag).

The my.obr.name mention is the id of the server to put in the settings.xml file for authentication.

To achieve this, I read the following sites:

http://www.flexthinker.com/2012/06/release-an-osgi-bundle-into-an-obr-with-maven/

http://books.sonatype.com/mcookbook/reference/ch01s09.html

In felix, you just have to do:

g! obr:repos add ftp://obr.example.com/repository.xml
g! obr:deploy my-artifact

The only problem I still have is that the dependencies are not listed on the repository.xml file.

Maybe you can work with Eclipse Orbit to retrieve some dependencies :

http://download.eclipse.org/tools/orbit/downloads/

https://bugs.eclipse.org/bugs/show_bug.cgi?id=406259

But I did not try this yet.

like image 23
Ben Avatar answered Oct 24 '22 12:10

Ben