Java Reference
In-Depth Information
RegistryEvent
Handles
RegistryListener
HashMap
Subscribe
Uses
ExportedServiceTracker
Aggregates
Publish
Extends
RemoteRegistry
Subscribe
ImportedServiceListenerHook
BundleContext
DummyRegistry
Provides
ImportedServiceFindHook
Publish
RemoteServiceReference
Figure 15.10 Simple registry scheme that abstracts mechanism of service discovery
Remote Services Admin
If you're interested in building this sort of technology, we advise you to look at the
Remote Services Admin chapter of the OSGi R4.2 Enterprise specification. It provides
a more complete model for building pluggable discovery and transport schemes, but
it goes beyond the scope of this topic.
During this example, we'll focus on the following classes:
ExportedServiceTracker
ImportedServiceListenerHook
ImportedServiceFindHook
But before we get there, let's look briefly at the other classes in this diagram. The Remote-
Registry interface provides a simple lookup and listener scheme similar to those of
the OSG i service registry. The RegistryListener interface receives notifications of
RegistryEvent s, which contain details of added or removed RemoteServiceReference s.
For the purposes of providing a concrete implementation of this API , you'll imple-
ment a DummyRegistry that performs no remote communication at all; instead, it
tracks the available remote services using a java.util.HashMap .
Hash map?
You may think we're cheating a little by using a HashMap in this example—and we
are. But this HashMap -based approach demonstrates all the key functionality of im-
plementing a Remote Services distribution provider, which involves dealing with an
externally managed service registry. By necessity, we must ignore the complex issues
in the area of distributed computing, such as network-discovery protocols, remote pro-
cedure calls, and object marshaling. These are all important topics, but they're beyond
the scope of this topic. We leave you as architects or developers with the task of choos-
ing your favorite distributed technologies if you wish to implement a real remote registry.
Search WWH ::




Custom Search