August 2001
Intermediate to advanced
480 pages
9h 14m
English
We have seen that the framework maintains a service registry to which a bundle can publish its service by calling the registerService method and from which another can get the service by calling the getServiceReference(s) then getService methods on the BundleContext interface. However, it may not be apparent that you can in fact register any type of object with the registry.
For example, the following snippet is entirely valid, although probably not useful:
for (int i = 0; i < 100; i++)
bundleContext.registerService(
"java.lang.Integer", new Integer(i));
And the following call would then return 100 service references to Integer objects in the array
ServiceReference[] ref = bundleContext.getServiceReferences( ...
Read now
Unlock full access