Page 3 of 4
The join process
Once a service provider has a service registrar object, the end product of discovery, it is ready to do a join -- to become
part of the federation of services that are registered in the lookup service. To do a join, the service provider invokes the
register() method on the service registrar object, passing as a parameter an object called a service item, a bundle of objects that describe the service. The register() method sends a copy of the service item up to the lookup service, where the service item is stored. Once this has completed,
the service provider has finished the join process: its service has become registered in the lookup service.
The service item is a container for several objects, including an object called a service object, which clients can use to interact with the service. The service item can also include any number of attributes, which can be any object. Some potential attributes are icons, classes that provide GUIs for the service, and objects that give more information about the service.
Service objects usually implement one or more interfaces through which clients interact with the service. For example, a lookup
service is a Jini service, and its service object is the service registrar. The register() method invoked by service providers during join is declared in the ServiceRegistrar interface, which all service registrar objects implement. Clients and service providers talk to the lookup service through
the service registrar object by invoking methods declared in the ServiceRegistrar interface. Likewise, a disk drive would provide a service object that implemented some well-known storage service interface.
Clients would look up and interact with the disk drive by this storage service interface.
The lookup process
Once a service has registered with a lookup service via the join process, that service is available for use by clients who
query that lookup service. To build a distributed system of services that will work together to perform some task, a client
must locate and enlist the help of the individual services. To find a service, clients query lookup services via a process
called lookup.
To perform a lookup, a client invokes the lookup() method on a service registrar object. (A client, like a service provider, gets a service registrar through the process of
discovery, as described earlier in this article.) The client passes as an argument to lookup() a service template, an object that serves as search criteria for the query. The service template can include a reference to an array of Class objects. These Class objects indicate to the lookup service the Java type (or types) of the service object desired by the client. The service
template can also include a service ID, which uniquely identifies a service, and attributes, which must exactly match the attributes uploaded by the service provider
in the service item. The service template can also contain wildcards for any of these fields. A wildcard in the service ID
field, for example, will match any service ID. The lookup() method sends the service template to the lookup service, which performs the query and sends back zero to many matching service
objects. The client gets a reference to the matching service objects as the return value of the lookup() method.
In the general case, a client looks up a service by Java type, usually an interface. For example, if a client needed to use
a printer, it would compose a service template that included a Class object for a well-known interface to printer services. All printer services would implement this well-known interface. The
lookup service would return a service object (or objects) that implemented this interface. Attributes can be included in the
service template to narrow the number of matches for such a type-based search. The client would use the printer service by
invoking on the service object methods declared in the well-known printer service interface.
Jini's architecture brings object-oriented programming to the network by enabling network services to take advantage of one of the fundamentals of object-oriented programming: the separation of interface and implementation. For example, a service object can grant clients access to the service in many ways. The object can actually represent the entire service, which is downloaded to the client during lookup and then executed locally. Alternatively, the service object can serve merely as a proxy to a remote server. When the client invokes methods on the service object, it sends the requests across the network to the server, which does the real work. The local service object and a remote server can each do part of the work as well.
One important consequence of Jini's architecture is that the network protocol used to communicate between a proxy service object and a remote server does not need to be known to the client. As illustrated in the figure below, the network protocol is part of the service's implementation. This protocol is a private matter decided upon by the developer of the service. The client can communicate with the service via this private protocol because the service injects some of its own code (the service object) into the client's address space. The injected service object could communicate with the service via RMI, CORBA, DCOM, some home-brewed protocol built on top of sockets and streams, or anything else. The client simply doesn't need to care about network protocols, because it can talk to the well-known interface that the service object implements. The service object takes care of any necessary communication on the network.

The client talks to the service through a well-known interface
Different implementations of the same service interface can use completely different implementation approaches and completely different network protocols. A service can use specialized hardware to fulfill client requests, or it can do all its work in software. In fact, the implementation approach taken by a single service can evolve over time. The client can be sure it has a service object that understands the current implementation of the service, because the client receives the service object (by way of the lookup service) from the service provider itself. To the client, a service looks like the well-known interface, regardless of how the service is implemented.
listserv@java.sun.com. In the body of the message, type subscribe jini-users
jiniBy Anonymous on January 6, 2009, 10:57 amsuperb topic is jini technology its sumthing really fresh to my search really dedicated work thanks publish lot more information regarding jini please
Reply | Read entire comment
View all comments