OPS4J
  Pax Runner - Deprecated
Added by Niclas Hedhman, last edited by Alin Dreghiciu on Sep 09, 2007  (view change)

Labels

 
(None)

If any of the following is true;

  • You often change from one OSGi platform to another.
  • You don't know what OSGi is, but want to spend half an hour checking it out.
  • You can't be bothered about following the setup and requirements README for the OSGi platform of your choice.
  • You have problem to get the OSGi platform working at all.

then perhaps the Pax Runner can help.

And it will not take you very long to find out. Try the following steps;

  1. Download http://repository.ops4j.org/maven2/org/ops4j/pax/runner/LATEST/pax-runner.jar
  2. Save the file in a new directory ($ROOT)
  3. Go to that directory.
  4. Test java -version in order to ensure you have a Java 5 level JRE installed (the demo uses Wicket, the Runner runs on less)
  5. java -jar pax-runner.jar --platform=equinox org.ops4j.pax.wicket.samples.departmentstore demo 0.2.1
    or with proxy:
    java -Dhttp.proxyHost=<myproxy> -Dhttp.proxyPort=8080 -jar pax-runner-0.2.0-SNAPSHOT.jar --platform=knopflerfish --proxy-username=<myusername> --proxy-password=<mypassword> org.ops4j.pax.wicket.samples.departmentstore demo 0.2.1
  6. Open a browser and go to http://localhost:8080/deptStore

You have now asked to start Equinox with the DepartmentStore Demo from the Pax Wicket project.

That Simple!

Now, do the following instead;
java -jar pax-runner.jar --platform=knopflerfish org.ops4j.pax.wicket.samples.departmentstore demo 0.2.1
Voila! Knopflerfish starts instead of Equinoxbut the sample is the same. At the time of writing, Apache Felix has not made a release yet, so it is not yet available, but will be real soon.

And you can do
java -jar pax-runner.jar --gui --platform=knopflerfish org.ops4j.pax.wicket.samples.departmentstore demo 0.2.1
to ask for a more user-friendly GUI (not in Equinox).

Guide

How does this work?

The commandline argument you provide points to a Maven POM (Project Object Model). The POM lists the dependencies, and those are expected to be OSGi bundles, which are downloaded, installed and started on the platform of choice. Pax Runner will check the $HOME/.m2/repository directory locally first, and use the POM and/or bundles found there.

Only bundles can be specified in the POM that is starting, so one need to prepare the POM to describe the full application in bundle terms.

It is currently not possible to load anything but ONE POM in Pax Runner.

Command line

The formal commandline for the Pax Runner is;

java -jar pax-runner.jar [options] [<groupId>] <artifactId> [<version>]
 or
java -jar pax-runner.jar [options] <pom-URL>
 or
java -jar pax-runner.jar [options]

Defaults;
If no group, artifact and version specified, the Pax Wicket Demo will be started.
If no version is specified, LATEST will be used and looked up in the Maven repository.
If no group is specified, org.ops4j.pax.apps will be used.

Arguments;
groupId - Maven groupId of the application to load.
artifactId - Maven artifactId of the application to load.
version - The version of the above.
URL - The direct URL of the Maven POM, that will be read to load the application.

Options;" );
-p <platform> - The OSGi platform to use. Default: equinox
--platform=<platform> - The OSGi platform to use. Default: equinox
--clean - Do not load persisted state. Default: false
--gui - Load GUI (if supported by platform)
--no-md5 - Disable MD5 checksum checks for downloads.
--dir=<workdir> - Which directory to use. Default: runner/
--profile=<profile> - Which profile to run (if supported by platform)
--repository=<repo> - Which repository to download from. Default: repository.ops4j.org
--proxy-username=<pwd> - Username for the proxy.
--proxy-password=<pwd> - Username for the proxy.
--repository-username=<pwd> - Username for the repository server.
--repository-password=<pwd> - Username for the repository server.

POM Goodies

It is also possible to specify properties in the POM, and those will be carried into the OSGi platform. For instance, if you are deploying an OSGi HTTPService (as the example above is doing) you might want to set the port of the Http listener. You do that in the application POM like this;

<project>
 <!- other stuff here ->
 <properties>
 <org.osgi.service.http.port>2080</org.osgi.service.http.port>
 <org.osgi.service.http.port.secure>2443</org.osgi.service.http.port.secure>
 </properties>
 <!- and here ->
</project>

Other Pax Runners

  1. Niclas Hedhman is working on a Pax Runner for IDEA in the laboratory. Check it out if you are a IDEA user.