Developing
A Simple Jini Client
Gopalan Suresh Raj
Note |
To
work with any of these samples, you will need the
following: .........................................The Java 2 compiler and API - JDK 1.2 .........................................The Jini 1.x System Software |
This simple Jini client Queries the Jini Service for it's current time in milliseconds by invoking it's getTime() method. It then computes the time taken for the message to reach it and prints it out in milliseconds.
The Steps involved in developing a Jini Client are
1. Code the Jini Client
2. Start the Client
1. Code the Jini Client
MyClient.java |
import
net.jini.core.entry.*; import net.jini.core.lookup.*; import net.jini.core.discovery.*; import net.jini.lookup.*; import net.jini.lookup.entry.*; import net.jini.discovery.*; import java.rmi.*; MyClient -- The Jini Client Class ***************************************************************************/ class MyClient { try { /* /* /* /* |
4. Startup the Client
H:\jini\TimeServer> H:\jini\TimeServer>set CLASSPATH=.;G:\sun\jini\jini1_0\lib\jini-core.jar;G:\sun\jini\jini1_0\lib\jini-ext.jar; G:\sun\jini\jini1_0\lib\mahalo.jar;G:\sun\jini\jini1_0\lib\mahalo-dl.jar;G:\sun\jini\jini1_0\lib\reggie.jar; G:\sun\jini\jini1_0\lib\reggie-dl.jar;G:\sun\jini\jini1_0\lib\sun-util.jar;G:\sun\jini\jini1_0\lib\tools.jar; %CLASSPATH% H:\jini\TimeServer> H:\jini\TimeServer>java -Djava.security.policy=H:\jini\TimeServer\policy.all -Djava.rmi.server.codebase=http://localhost/ MyClient client: LookupLocator = jini://localhost/ client: LookupLocator.host = localhost client: LookupLocator.port = 4160 client: ServiceRegistrar = com.sun.jini.reggie.RegistrarProxy@2cd27317 client: ServiceID = 88fc7d88-8ea6-4db9-9cac-ddeab6249ecc client: ServiceTemplate = net.jini.core.lookup.ServiceTemplate@f82dd4d7 client: Service object = MyServer_Stub[RemoteStub [ref: [endpoint:[130.151.69.105:3980](remote),objID:[4c85d4c7:d5f eec9ba4:-8000, 0]]]] client: Time at server is 919104970506 client: Time at client is 919104970506 client: Time for message to traverse the net is --->0.0 msecs<--- H:\jini\TimeServer>java -Djava.security.policy=H:\jini\TimeServer\policy.all -Djava.rmi.server.codebase=http://localhost/ MyClient client: LookupLocator = jini://localhost/ client: LookupLocator.host = localhost client: LookupLocator.port = 4160 client: ServiceRegistrar = com.sun.jini.reggie.RegistrarProxy@2cd27317 client: ServiceID = 88fc7d88-8ea6-4db9-9cac-ddeab6249ecc client: ServiceTemplate = net.jini.core.lookup.ServiceTemplate@f82dd4b8 client: Service object = MyServer_Stub[RemoteStub [ref: [endpoint:[130.151.69.105:3980](remote),objID:[4c85d4c7:d5feec9ba4:-8000, 0]]]] client: Time at server is 919105007119 client: Time at client is 919105007119 client: Time for message to traverse the net is --->0.0 msecs<--- H:\jini\TimeServer>java -Djava.security.policy=H:\jini\TimeServer\policy.all -Djava.rmi.server.codebase=http://localhost/ MyClient client: LookupLocator = jini://localhost/ client: LookupLocator.host = localhost client: LookupLocator.port = 4160 client: ServiceRegistrar = com.sun.jini.reggie.RegistrarProxy@2cd27317 client: ServiceID = 88fc7d88-8ea6-4db9-9cac-ddeab6249ecc client: ServiceTemplate = net.jini.core.lookup.ServiceTemplate@f821d4bf client: Service object = MyServer_Stub[RemoteStub [ref: [endpoint:[130.151.69.105:3980](remote),objID:[4c85d4c7:d5feec9ba4:-8000, 0]]]] client: Time at server is 919105010724 client: Time at client is 919105010734 client: Time for message to traverse the net is --->10.0 msecs<--- H:\jini\TimeServer>java -Djava.security.policy=H:\jini\TimeServer\policy.all -Djava.rmi.server.codebase=http://localhost/ MyClient client: LookupLocator = jini://localhost/ client: LookupLocator.host = localhost client: LookupLocator.port = 4160 client: ServiceRegistrar = com.sun.jini.reggie.RegistrarProxy@2cd27317 client: ServiceID = 88fc7d88-8ea6-4db9-9cac-ddeab6249ecc client: ServiceTemplate = net.jini.core.lookup.ServiceTemplate@fb79d483 client: Service object = MyServer_Stub[RemoteStub [ref: [endpoint:[130.151.69.105:3980](remote),objID:[4c85d4c7:d5feec9ba4:-8000, 0]]]] client: Time at server is 919105014360 client: Time at client is 919105014370 client: Time for message to traverse the net is --->10.0 msecs<--- H:\jini\TimeServer>java -Djava.security.policy=H:\jini\TimeServer\policy.all -Djava.rmi.server.codebase=http://localhost/ MyClient client: LookupLocator = jini://localhost/ client: LookupLocator.host = localhost client: LookupLocator.port = 4160 client: ServiceRegistrar = com.sun.jini.reggie.RegistrarProxy@2cd27317 client: ServiceID = 88fc7d88-8ea6-4db9-9cac-ddeab6249ecc client: ServiceTemplate = net.jini.core.lookup.ServiceTemplate@f82dd486 client: Service object = MyServer_Stub[RemoteStub [ref: [endpoint:[130.151.69.105:3980](remote),objID:[4c85d4c7:d5feec9ba4:-8000, 0]]]] client: Time at server is 919105017744 client: Time at client is 919105017754 client: Time for message to traverse the net is --->10.0 msecs<--- H:\jini\TimeServer>java -Djava.security.policy=H:\jini\TimeServer\policy.all -Djava.rmi.server.codebase=http://localhost/ MyClient client: LookupLocator = jini://localhost/ client: LookupLocator.host = localhost client: LookupLocator.port = 4160 client: ServiceRegistrar = com.sun.jini.reggie.RegistrarProxy@2cd27317 client: ServiceID = 88fc7d88-8ea6-4db9-9cac-ddeab6249ecc client: ServiceTemplate = net.jini.core.lookup.ServiceTemplate@f82dd48a client: Service object = MyServer_Stub[RemoteStub [ref: [endpoint:[130.151.69.105:3980](remote),objID:[4c85d4c7:d5feec9ba4:-8000, 0]]]] client: Time at server is 919105021370 client: Time at client is 919105021380 client: Time for message to traverse the net is --->10.0 msecs<--- H:\jini\TimeServer>java -Djava.security.policy=H:\jini\TimeServer\policy.all -Djava.rmi.server.codebase=http://localhost/ MyClient client: LookupLocator = jini://localhost/ client: LookupLocator.host = localhost client: LookupLocator.port = 4160 client: ServiceRegistrar = com.sun.jini.reggie.RegistrarProxy@2cd27317 client: ServiceID = 88fc7d88-8ea6-4db9-9cac-ddeab6249ecc client: ServiceTemplate = net.jini.core.lookup.ServiceTemplate@fb79d489 client: Service object = MyServer_Stub[RemoteStub [ref: [endpoint:[130.151.69.105:3980](remote),objID:[4c85d4c7:d5feec9ba4:-8000, 0]]]] client: Time at server is 919105024785 client: Time at client is 919105024785 client: Time for message to traverse the net is --->0.0 msecs<--- H:\jini\TimeServer> |
click here to go
to the Developing a Simple Jini Service Page... |
click here to go to My Jini HomePage... |
This site was developed and is maintained by Gopalan Suresh Raj This page has been visited times since February 12,1999. |
Last Updated : Feb 12, '99 |
Copyright (c) 1997-99, Gopalan Suresh Raj - All rights reserved. Terms of use. |
All products and companies mentioned at this site,are trademarks of their respective owners. |