2
edits
Changes
no edit summary
----------
<h4>34. Define the Bundle Service Provider</h4>
The service ''bookfinder'' could be used only if there is a bundle that implements the service. The bundle ''cs.ecl.osgi.simple.bookfinderservice'' implements ''BundleActivator'' interface in the ''Activator'' class. This bundle will be called 'service provider'.
<h5>34.1 Define the Activator class for the service provider</h5>
<source lang="java">
package cs.ecl.osgi.simple.bookfinderservice;
</source>
<h5>3.2 Define the service implementation class for the service </h5>
The class must be defined in an internal package ''cs.ecl.osgi.simple.bookfinderservice.internals'' <u>The package will not be exposed to the outside world</u>
----------
<h4>34. Define the Bundle Service Consumer</h4>
The service ''bookfinder'' could be used only if there is a bundle that requests its service. The bundle ''cs.ecl.osgi.simple.bookfindconsumer'' by the time is activated ''BundleActivator'' looks for the service in the registry. This bundle will be called 'service consumer'.
<h5>34.1 Define the Activator class for the service consumer</h5>
<source lang="java">
package cs.ecl.osgi.simple.bookfinderconsumer.bookfinderconsumer;
context.ungetService(reference);
}
</source>
The ''class org.osgi.framework.BundleContext'' defines the bundle's execution context within the Framework. The context is used to grant access to other methods so that this bundle can interact with the Framework.
BundleContext methods allow a bundle to:
* Subscribe to events published by the Framework.
* Register service objects with the Framework service registry.
* Retrieve ServiceReferences from the Framework service registry.
* Get and release service objects for a referenced service.
* Install new bundles in the Framework.
* Get the list of bundles installed in the Framework.
* Get the Bundle object for a bundle.
<h5>4.2 Define the MANIFEST.MF for the ''cs.ecl.osgi.simple.bookfinderservice'' bundle</h5>
<source lang="xml">
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Bookfinderconsumer
Bundle-SymbolicName: cs.ecl.osgi.simple.bookfinderconsumer
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: cs.ecl.osgi.simple.bookfinderconsumer.bookfinderconsumer.Activator
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: cs.ecl.osgi.simple.bookfinder,
org.osgi.framework;version="1.3.0"
Bundle-Vendor: Seneca College - Eclipse Course
Require-Bundle: org.eclipse.osgi;bundle-version="3.6.1"
</source>