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

Compare with Current View Page History

« Previous Version 2 Next »

work in progress

Launching a JCR Repository inside Equinox

Today I was contacted with a request to setup the jcr/jackrabbit-server bundle in an OSGi framework such that a JCR Repository is being started and can be accessed from within the OSGi framework and over RMI from outside of the framework. It happens to be that the framework of choice has been Equinox.

So, to better support I decided to setup my own Equinox framework and install required bundles.

Getting the Equinox Framework

First of all, you need the Equinox OSGi framework. You can grab this from the Equinox download page at http://download.eclipse.org/eclipse/equinox/. I decided to use the latest release stuff, which at the time of this writing is 3.3.2. So I downloaded the framework jar file org.eclipse.osgi_3.3.2.R33x_v20080105.jar

One this has been downloaded, it can easily be started from the command line. As I required the console prompt, I added the -console command line option:

$ java -jar org.eclipse.osgi_3.3.2.R33x_v20080105.jar -console

osgi> ss

Framework is launched.

id      State       Bundle
0       ACTIVE      org.eclipse.osgi_3.3.2.R33x_v20080105

osgi> 

The console gives you the osgi> prompt to which I entered a first ss command to get a short status of installed bundles. This lists just the system bundle with ID 0. This console is used by us to interactively install and start additional bundles, until we get a running Jackrabbit Repository.

To get a list of available commands just enter the help command. Some commands which we will use later on are :

  • ss – display a short status list of installed bundles
  • status – display a long status list of installed bundles
  • bundle <id> – display detailed information on the bundle with the given <id>. This list includes registered and used services, import and export packages and some more information.
  • install <url> – installs a bundle from the given <url>. Note that this must be a real URL, that is to install a file from the local filesystem, the file: protocoll must be specified.
  • start <id> – starts the bundle with the given <id>.
  • stop <id> – stops the bundle with the given <id>.
  • uninstall <id> – uninstalls the bundle with the given <id>.

OSGi Compendium

First we need to install OSGi Compendium Services bundles:

  1. The Compendium Services API bundle
  2. A LogService implementation
  3. A Configuration Admin Service implementation
  4. A Declarative Services implementation

We chose to mainly use Equinox implementations, so we get the org.eclipse.osgi.services_3.1.200.v20070605.jar bundle to install the OSGi Compendium Services API:

osgi> install <url>
Bundle id is 1

osgi> start 1

osgi> ss

Framework is launched.

id      State       Bundle
0       ACTIVE      org.eclipse.osgi_3.3.2.R33x_v20080105
1       ACTIVE      org.eclipse.osgi.services_3.1.200.v20070605

osgi> 

Note that bundles are not automatically started after the installation. Therefore we have to manually start the bundles after the installation. This manual start is only required after the installation. On framework restarts all bundles, which were started when the framework was last shutdown, are automatically restarted.

We continue with the LogService. Here we could of course also choose to use the Equinox implementation. But as I know, that Jackrabbit uses SLF4J for logging and some other components use log4j and Jakarta Commons Logging, I strongly suggest to use the LogService implementation from the Sling project. This bundle unifies all logging requests from the OSGi LogService and the SLF4J, log4j and Jakarta Commons Logging API into a single log channel. This makes problem traking much easier.

The Sling LogService implementation is available from the Apache Snapshot repository and may be directly installed into the OSGi framework:

osgi> install http://people.apache.org/repo/m2-snapshot-repository/org/apache/sling/org.apache.sling.osgi.log/2.0.0-incubator-SNAPSHOT/org.apache.sling.osgi.log-2.0.0-incubator-20080430.113337-26.jar
Bundle id is 2

osgi> start 2 
30.04.2008 21:13:24.642 *INFO* [OSGi Console] org.apache.sling.osgi.log.LogServiceFactory LogManager: Logging set up from context
30.04.2008 21:13:24.645 *INFO* [OSGi Console] org.apache.sling.osgi.log Service [org.apache.sling.osgi.log.LogServiceFactory,22] ServiceEvent REGISTERED
30.04.2008 21:13:24.646 *INFO* [OSGi Console] org.apache.sling.osgi.log Service [org.apache.sling.osgi.log.LogReaderServiceFactory,23] ServiceEvent REGISTERED

osgi> 30.04.2008 21:13:24.646 *INFO* [Framework Event Dispatcher] org.apache.sling.osgi.log BundleEvent STARTED


osgi> ss

Framework is launched.

id      State       Bundle
0       ACTIVE      org.eclipse.osgi_3.3.2.R33x_v20080105
1       ACTIVE      org.eclipse.osgi.services_3.1.200.v20070605
2       ACTIVE      org.apache.sling.osgi.log_2.0.0.incubator-SNAPSHOT

osgi> 

This is a complete list of the links to the files we needed during download. Note, that some links are behind a mirroring scripts (mostly the Equinox download links).

Description

Link

Equinox OSGi Framework

org.eclipse.osgi_3.3.2.R33x_v20080105.jar

OSGi Compendium Services API

org.eclipse.osgi.services_3.1.200.v20070605.jar

Sling OSGi LogService Implementation

org.apache.sling.osgi.log-2.0.0-incubator-20080430.113337-26.jar

  • No labels