Noel Enete
Search for Lookup


This is an example of how to search for the Jini lookup service. It also includes information for how to run the client and the server on two different machines that are on the same subnet.
  1. Run example
  2. Client
  3. Server
  4. ServerInterface
  5. Compile example

Run Instructions


Start Jini.

Edit the JiniExample3 SetInstallPoint script file.

Start the web server and the Jini service.

  • Open a new command line and change to the server run directory: \java \nuggets \pages \examples \JiniExample3 \server-side (remove the spaces from the path). Run the web server program by executing the r1 script file.
  • Open a new command line and change to the same directory: \java \nuggets \pages \examples \JiniExample3 \server-side (remove the spaces from the path). Run the server program by executing the r2 script file.

Start the client.

  • Wait until the server is up (~15 seconds) then open a new command line and change to the client run directory: \java \nuggets \pages \examples \JiniExample3 \client-side (remove the spaces from the path). Run the client program by executing the r script file.

To run this example first start Jini:
  • If the client and server are on separate machines: look to the notes for starting client or server to find out how to start Jini for each machine. Note: Jini's discovery process uses multicast IP packets which are not normally enabled between machines on different networks or on different subnets. For this reason, make sure both of your machines are on the same subnet.
  • Otherwise, start Jini from the JiniExample1 directory using the r1.bat, r2.bat, and r3.bat files.

Then move the webserver files from this example to the webserver directory:

  • Since each compile job deletes all the class files from the Jini lib directory, always recompile the example using the c.bat file (which performs the copy for you) before using the example.

Then start the server:

  • If the client and server are on separate machines: copy the \java\nugget and the \java\jini.100 trees over to the server machine retaining the directory names. Then edit THIS_HOSTIP in the \java \nugget \pages \examples \JiniExample3 \SetInstallPoint.bat file to point to the IP address of the machine upon which the server is running.
  • Open a new command line and change to the server run directory: \java \nuggets \pages \examples \JiniExample3 \server-side.
  • If the client and server are on separate machines: start Jini (http, rmid, and reggie) for this machine by executing r1.bat, r2.bat, and r3.bat from this server-side directory.
  • Run the server program by executing the r.bat script file.

Then start the client:

  • If the client and server are on separate machines: copy the \java\nugget and the \java\jini.100 trees over to the client machine retaining the directory names. Then edit THIS_HOSTIP in the \java \nuggets \pages \examples \JiniExample3 \SetInstallPoint.bat file to point to the IP address of the machine upon which the client is running. (You do NOT need to start http, rmid, or reggie on the client machine.)
  • Wait until the server is up (about 15 seconds) then open a new command line and change to the client run directory: \java \nuggets \pages \examples \JiniExample3 \client-side.
  • Run the client program by executing the r.bat script file.

Client


The client does not know where the lookup service is, so in the constructor, it instantiates a LookupDiscovery object to initiate the multicast discovery protocol. The client has implemented the DiscoveryListener protocol so it can receive notice when a lookup service has been discovered.





Figure 2: MyClient


When one or more lookup services have been discovered, Jini calls the discovered() method of this client. It passes an event from which the lookup services are extracted. This client iterates through each lookup service and prints each service found in each lookup service.

Server


The server works substantially the same as the client in the way it searches for the lookup service.






Figure 3: MyServer


Server Interface


There is nothing new in this server interface.


Figure 4: MyServerInterface




by Noel Enete . . . www.enete.com . . . noel@enete.com