The Maven Cookbook
1.11. Grouping OSGi Bundle Repositories
So far in this chapter, you've deployed an artifact to a Maven repository and consumed it using a Virtual OBR repository as a bridge between Maven and OSGi. In the previous recipe, you proxied a remote OBR repository using a Nexus proxy repository. In this recipe, you are going to learn how to consolidate multiple OBR repositories into a single URL using a Nexus repository group.
You need to consolidate a number of Nexus OBR repositories into a single OBR repository interface. You have a collection of Proxy, Virtual, and Hosted OBR repositories, and you want to connect your OSGi aware systems to a single OBR repository, reducing the number of moving parts involved in your current deployment procedures.
Create a OBR repository group in Nexus Professional which combines one or more OBR repositories into a single repository. To do this:
-
Load the Nexus interface in a web browser by opening the URL http://localhost:8081/nexus.
-
Login as an administrative user using the default credentials of admin/admin123 (if you haven't already changed the default password).
-
Click on Repositories in the left navigation menu.
-
Click on the Add.. button above the list of Nexus repositories and groups.
-
Select "Repository Group" from the resulting dropdown.
-
In the New Repository Group window, supply the following values as shown in Figure 1.10, “Creating a New OBR Group”:
-
Group ID: obr-group
-
Group Name: OBR Group
-
Provider: OBR Group
-
-
Drag the two OBR repositories created in the previous recipes to the Ordered Group Repositories list.
-
Click the Save button to create the new Repository Group.
To verify that the new OBR repository group is generating the the
appropriate XML combining the Felix OBR reposiotry and the Snapshots OBR
repository, click on Repositories in the left navigation menu, and then
select "OBR Group" from the list of repositories. If you look at the
Browse tab for this repository and drill into the
.meta/
directory, you can then right-click on the
obr.xml
file and select
from the context menu. The URL for
this group's repository XML should be http://localhost:8081/nexus/content/groups/obr-group/.meta/obr.xml.
Again,bBe warned, this is going to be an even larger XML file than the
repository XML for the Felix OBR proxy. Search for mcookbook and note
that the repository also contains references to all of the artifacts
from the remote Felix OBR repository. The Nexus Professional OBR
repository group has effectively merged the contents of these two
repositories into a single unified interface which will simplify your
system's interaction to a single URL.
If you want to see the contents of this repository group, install Felix and add a reference to the Nexus repository group:
-
Download Apache Felix from http://www.apache.org/dist/felix/felix-1.8.0.tar.gz.
-
Unpack the Felix distribution on your local workstation.
-
Change directory to the Felix directory.
-
Start Apache Felix with java -jar ./bin/felix.jar
-
Add the Snapshots repository as an OBR repository by copying the URL to the repository.xml and passing it to the obr command: obr add-url http://localhost:8081/nexus/content/groups/obr-group/.meta/obr.xml
-
List the contents of the OBR repository.
-
Verify that the group contains bundles from Felix and the bundle from the osgi-project.
These commands are captured in the following screen listing:
~/programs $ wget http://www.apache.org/dist/felix/felix-1.8.0.tar.gz --2009-07-14 22:46:19-- http://www.apache.org/dist/felix/felix-1.8.0.tar.gz Resolving www.apache.org... 140.211.11.130 Connecting to www.apache.org|140.211.11.130|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 901620 (880K) [application/x-gzip] Saving to: `felix-1.8.0.tar.gz' 2009-07-14 22:46:20 (924 KB/s) - `felix-1.8.0.tar.gz' saved [901620/901620] ~/programs $ tar xvzf felix-1.8.0.tar.gz felix-1.8.0/ felix-1.8.0/bin/ felix-1.8.0/bin/felix.jar ... felix-1.8.0/NOTICE ~/programs $ cd felix-1.8.0 ~/programs/felix-1.8.0 $ java -jar ./bin/felix.jar Welcome to Felix. ================= -> obr add-url http://localhost:8081/nexus/content/groups/obr-group/.meta/obr.xml -> obr list Apache Felix Bundle Repository (1.2.1, ...) Apache Felix Configuration Admin Service (1.0.4, ...) Apache Felix Declarative Services (1.0.8, ...) Apache Felix EventAdmin (1.0.0) Apache Felix File Install (1.2.0, ...) Apache Felix HTTP Service Jetty (1.0.1, ...) Apache Felix iPOJO (1.2.0, ...) Apache Felix iPOJO (0.8.0) Apache Felix iPOJO Arch Command (1.2.0, ...) Apache Felix iPOJO Composite (1.2.0) Apache Felix iPOJO Composite (1.0.0, ...) Apache Felix iPOJO Event Admin Handler (1.2.0, ...) Apache Felix iPOJO Extender Pattern Handler (1.2.0) Apache Felix iPOJO Extender Pattern Handler (1.0.0, ...) Apache Felix iPOJO JMX Handler (1.2.0, ...) Apache Felix iPOJO Temporal Service Dependency Handler (1.2.0, ...) Apache Felix iPOJO White Board Pattern Handler (1.2.0, ...) Apache Felix Log Service (1.0.0) Apache Felix Metatype Service (1.0.2, ...) Apache Felix Prefrences Service (1.0.2) Apache Felix Remote Shell (1.0.2) Apache Felix Shell Service (1.0.2, ...) Apache Felix Shell TUI (1.0.2, ...) Apache Felix UPnP Base Driver (0.8.0) Apache Felix UPnP Extra (0.4.0) Apache Felix UPnP Tester (0.4.0) Apache Felix Web Management Console (1.2.10, ...) org.sonatype.mcookbook (1.0.0.SNAPSHOT, ...) OSGi OBR Service API (1.0.0) OSGi R4 Compendium Bundle (4.0.0) Servlet 2.1 API (1.0.0) ->
As anticipated, the list of bundles in the group repository
contains all of the bundles from the Apache Felix repository and the
bundle from the Snapshots OBR repository -
org.sonatype.mcookbook
.