Java Reference
In-Depth Information
The relevant bits are in bold. It tells the plug-in to add to our MANIFEST certain properties: an
Export-Package directive and a Bundle-Activator header. The Export-Package directive tells the OSGi
environment that this jar, a “bundle,” vends the classes in that package, and that those classes should be
made visible to the client. The Bundle-Activator directive describes to the OSGi environment which
class implements BundleActivator , and should be consulted when life-cycle events occur.
The preceding plug-in takes care of specifying upon which other bundles our bundle depends, using
the Import-Package directive. The final, resulting MANIFEST.MF is telling.
Manifest-Version: 1.0
Export-Package: com.apress.springenterpriserecipes.osgi.
Private-Package: com.apress.springenterpriserecipes.osgi.helloworld.service,
Built-By: Owner
Tool: Bnd-0.0.311
Bundle-Name: helloworld-service
Created-By: Apache Maven Bundle Plugin
Bundle-Version: 1.0.0.SNAPSHOT
Build-Jdk: 1.6.0_14-ea
Bnd-LastModified: 1243157994625
Bundle-ManifestVersion: 2
Bundle-Activator: com.apress.springenterpriserecipes.osgi.
Import-Package: com.apress.springenterpriserecipes.osgi.helloworld.service,
Bundle-SymbolicName: com.apress.springenterpriserecipes.
This describes the dependencies, exports, and layout of the bundle fully to the OSGi runtime, and
makes it easy for clients to know what they're getting when they use this bundle. Take your compiled
classes, the finalized META-INF/MANIFEST.MF, and jar them up.
This rounds out the code for the service. Let's install it into the OSGi environment and then start in
using it as a client. The installation procedure is very specific to each tool.
Installing Equinox
Assuming that you've downloaded Equinox ( ; th is book was written
against 3.4.2) and unzipped it, change to the installation directory and, on the command line, type:
java -jar eclipse/plugins/org.eclipse.osgi_YOUR_VERSION.jar -console
Naturally, substitute YOUR_VERSION for the one that applies to the version of the distribution that
you downloaded. We're using 3.4, which is the latest stable release. This will start an interactive session.
You can type help to see the list of available commands. You can issue the services command to list the
bundles already installed. To install the bundle, assuming you've put the jar produced from previous
steps for the service at the root of your file system ( C:/ , or / , perhaps?) issue:
install file://helloworld-service-1.0-SNAPSHOT.jar o r install file:/C:/helloworld-service-
This installs the jar in the OSGi registry and produces an ID that can be used to refer to the bundle.
Use it as the operand to the start command.
Search WWH ::

Custom Search