|
Using the Service Discovery Manager
Version 1.00 May 14, 2004 |
|
LookupCacheBasicLookupCache.java.
A detailed explanation of that code follows.
The code in Sections 1, 2, 5, and 6 of Example 3 are the same as Sections 1, 2, 4, and 5 in Example 1, respectively, and are not covered again.
The code in Section 3 of Example 3 attempts to create a
LookupCache with a
TransactionManager template, a
null ServiceItemFilter object and
a null ServiceDiscoveryListener
object. The null
ServiceItemFilter means that no client-side
filtering is performed on any discovered service references.
The null ServiceDiscoveryListener
means that no client-side events are processed.
The code in Section 4 creates another null
ServiceItemFilter object so that no
second-level filtering is done on any cached service
references. Then the LookupCache's
lookup method is invoked. Keep in mind that the
LookupCache was created with the desired
service template already in place. Thus, any lookup request
on the cache will be based on that original template.
Again, the lookup method is a local, non-blocking
method invocation that operates on the cached set of service
references. Therefore, an explicit delay is still necessary
in order to give the discovery process time to populate the cache.
Keep in mind that the lookup cache is also performing all related cache management duties. It manages duplicate service registrations and duplicate event notifications from multiple lookup services. It manages the client-side filtering (which is covered later) for these service references. And finally, it maintains an updated "view" of the network by constantly monitoring the lookup discovery process.
The example can be run on a UNIX platform by doing the following:
$ cd bin12 (or bin20 for Jini 2.0 environments) $ run_basic_lookup_cache.sh
The example can be run on a Windows platform by doing the following:
$ cd bat12 (or bat20 for Jini 2.0 environments) $ run_basic_lookup_cache.bat
Assuming there is at least one publicly available lookup service and one publicly available transaction manager service, you should see output similar to the following:
pion 1089 =>run_basic_lookup_cache.sh + hostname CODEBASEHOST=pion + . JINI_HOME.sh EXJINIHOME=/files/jini1_2_1 + java -Djava.security.policy=../policy/policy.all -Djava.rmi.server.codebase=http://pion:8081/sdm-dl.jar -jar ../lib12/BasicLookupCache.jar Creating ServiceDiscoveryManager ... Creating ServiceTemplate for a net.jini.core.transaction.server.TransactionManager instance Creating LookupCache Attempting service lookup for a net.jini.core.transaction.server.TransactionManager instance TransactionManager found, id=bf6a0eaa-3d17-45e5-aed5-af2678406436SDM examples main page