TableOfContents

Introduction

[http://wiki.ops4j.org/confluence/display/ops4j/Pax Pax] is a project to develop tools for OSGi bundles. Pax-Construct, which is a part of Pax project, is a tool to create, build, manage and deploy OSGi bundles. The basic idea is that instead of writing all pom.xml files manually, generate those using simple shell commands.

Create New OSGi Project

PAX_HOME/pax-construct-1.3/bin

##############################################
# Template for Spring-OSGi projects #
##############################################

# (1) Create Project "project1"
pax-create-project -g org.cytoscape -a project1
cd project1

# (2) Add SpringSource Enterprise Bundle Repositories
pax-add-repository -i com.springsource.repository.bundles.release -u http://repository.springsource.com/maven/bundles/release
pax-add-repository -i com.springsource.repository.bundles.external -u http://repository.springsource.com/maven/bundles/external

# (3) Import required bundles
pax-import-bundle -g org.springframework.osgi -a org.springframework.osgi.extender -v 1.1.0 -- -DimportTransitive -DwidenScope
pax-import-bundle -g org.slf4j -a com.springsource.slf4j.simple -v 1.5.0
pax-import-bundle -g org.slf4j -a com.springsource.slf4j.api -v 1.5.0
pax-import-bundle -g org.aopalliance -a com.springsource.org.aopalliance -v 1.0.0
pax-import-bundle -g org.objectweb.asm -a com.springsource.org.objectweb.asm -v 3.1.0

# (4) Create bundles
pax-create-bundle -p org.cytoscape.helloservice -- -Dspring -Djunit
pax-create-bundle -p org.cytoscape.helloserviceuser -- -Dspring -Djunit

# (5) Build and run the project
mvn clean install pax:provision

Description for Each Section

  1. pax-create-project command creates a new OSGi project in the current working directory. By -g option, you can specify group id of this project.

  2. In general, you CANNOT use existing library files (jar files registered at the maven central repository) as OSGi bundle. There are two options to solve this problem:

    • Wrap existing jar files by pax-wrap-jar command

    • Use OSGi bundle repository instead of maven central repository

    In this example, I used the second option. pax-add-repository command adds an additional maven repository location to the pom file. SpringSource manages a maven repository [http://www.springsource.com/repository/app/ SpringSource Enterprise Bundle Repository], which is a repository of OSGi bundles. All library files in this repository are wrapped as OSGi bundles.

  3. pax-import-bundle command automatically generates <dependency> statement in the project pom file. In this example, bundles required to run [http://www.springframework.org/osgi Spring Dynamic Modules] are imported.

Useful Commands

Funding for Cytoscape is provided by a federal grant from the U.S. National Institute of General Medical Sciences (NIGMS) of the Na tional Institutes of Health (NIH) under award number GM070743-01. Corporate funding is provided through a contract from Unilever PLC.

MoinMoin Appliance - Powered by TurnKey Linux