I could not find a version with OSGi headers for the remaining dependency, json
. Maybe they'll be added by the time you cast your eyes on this (a little research before the selection of the dependency to install is always recommended).
However, depending on functionality in a JAR that doesn't hold OSGi headers is not an unlikely predicament to find yourself in.
The steps to work around such situation are not complicated. Here, you'll see one way of doing it— the manual way, which works well for very simple JARs like this one. In Chapter 14, Pitfalls and Troubleshooting, you'll be introduced to another way of achieving a similar result, using the BND tool. This tool goes deeper into the analysis of the JAR to be augmented with OSGi headers.
The following are the steps to follow:
P:/projects/felixbook/repackaged/
. META-INF/MANIFEST.MF
. Not a lot of headers are needed for a simple library dependency— the exported packages and a few additional headers for a clean display and proper version registration (for potential updates later).The Manifest should look like the following:
Manifest-Version: 1.0
Created-By: 1.6.0_07 (Sun Microsystems Inc.)
Export-Package: org.json
Bundle-Name: JSON
Bundle-Version: 20090211
Bundle-SymbolicName: org.json
org/json
. To keep the original JAR separate from the repackaged JAR, I've repackaged the updated one as json-20090211-osgi.jar
.g! repack = file:///P:/projects/felixbook/repackaged/
g! start $repack/json-20090211-osgi.jar
g! lb
START LEVEL 5
ID|State |Level|Name
0|Active | 0|System Bundle (3.0.1)
1|Active | 1|Apache Felix Bundle Repository (1.6.2)
2|Active | 1|Apache Felix Gogo Command (0.6.0)
3|Active | 1|Apache Felix Gogo Runtime (0.6.0)
4|Active | 1|Apache Felix Gogo Shell (0.6.0)
5|Active | 2|Bookshelf Inventory API (1.5.0)
6|Active | 1|Apache Felix iPOJO (1.6.4)
7|Active | 2|Bookshelf Inventory Impl - Mock (1.9.0)
8|Active | 1|Bookshelf Log Helper API (1.10.0)
9|Active | 1|Apache Felix Log Service (1.0.0)
10|Active | 1|Bookshelf Log Helper Impl (1.10.0)
11|Active | 3|Bookshelf Service (1.10.0)
12|Active | 5|Apache Felix iPOJO Gogo Command (1.0.0)
13|Active | 5|Bookshelf Service Gogo commands (1.10.0)
14|Active | 4|Apache Felix Http Jetty (2.0.4)
15|Active | 4|Apache Felix Http Whiteboard (2.0.4)
16|Active | 5|Bookshelf Servlet (1.11.0)
17|Active | 1|Apache Commons IO Bundle (1.4.0)
18|Active | 1|Apache Commons FileUpload Bundle (1.2.1)
19|Active | 1|JSON (20090211.0.0)
Let's install and start the web management console.