Java Reference
In-Depth Information
how services should behave in a distributed environment. In general, intents and con-
figuration should be kept to a minimum to allow distribution-provider flexibility. Let's
now turn our attention to the other side of the equation: client-side distributed services.
15.2.2
Consuming a web service
Returning to the stock-watcher example, what do you need to do it to make it use the
remote StockProvider service? Currently, it looks for the StockProvider service in
the OSG i service registry; what needs to change? With respect to your application,
nothing at all.
Because your client bundle runs in a separate JVM , all you need to do is install a
distribution provider into the client-side OSG i framework and configure it to discover
the distributed StockProvider service. The distribution provider will automatically
create a proxy of the remote service and inject it into the local service registry, which
the stock-watcher application will discover and use as normal. This scenario is shown
in figure 15.9.
If you're familiar with technologies such as Zeroconf, SSDP , UDDI , and Jini, you're
acquainted with the concept of discovery . Even if you aren't familiar with these technol-
ogies, it should be relatively intuitive that discovery is a pattern used in distributed
computing to allow a service provider to announce the presence of a service and for a
consumer to find it. Often, this is achieved using a central registry or peer-to-peer
mechanism, such as multicast TCP or multicast DNS . With such approaches, services
are discovered as needed by client applications. The Remote Services specification
provides an extensible pattern for implementing service discovery, which we'll cover
in more depth in the next section. For now, we'll look at what you need to do to con-
figure your distribution provider to discover the remote StockProvider service.
“Client” VM
“Server” VM
OSGi registry
OSGi registry
Endpoint
Service
provider
Service-provider
proxy
Distribution
provider
Distribution
provider
Announcement
Figure 15.9 The distribution provider bundle creates a remote endpoint for the service provider. It may
also announce the location and type of this endpoint for other distribution provider bundles to find. The
client-side distribution provider discovers remote endpoints and creates proxies to these services, which
it injects into the local OSGi service registry.
Search WWH ::




Custom Search