![]() |
Service with a User Interface
|
|---|
|
This is an example of a server that registers an applet with
Jini.
The client pulls the applet from Jini and launches it in a Frame window. When the applet's button is pressed, the applet uses Jini to find and call the server. All activity is logged to the standard output device. |
|
Edit the JiniExample2
Start the web server and the Jini service.
Start the client.
|
|
This is the client. Instead of fetching the server class from Jini,
it enumerates through the attributes of the server and launches the
applet attribute in a frame. The user is allowed to manipulate
the applet from there. When the button is pressed, a call is made to
the server object. All activity is written to the standard output
device of the client and the server windows.
|
|
Figure 2: MyClient |
|
This client is substantially like that of example1 except
the client does not need to have any knowledge of Instead of constructing attributes that look specifically
for To launch the applet, its Notice that this client has presented the user with an applet
that it found in Jini. The user can use the applet to interact
with its server. All of this happened without the client having
prior knowledge of the applet or the service.
|
|
The server registers itself with Jini and registers its
applet as one of the attributes it passes to Jini. The
activity is displayed on the standard output device.
|
|
Figure 3: MyServer |
|
The new idea is in the Then, any client can enumerate through this service's attributes
and test to see if the attribute is a subclass of Applet. If so,
the client can assume this is the service's user interface and
launch it for the user.
|
|
There is nothing new in this server interface.
|
|
Figure 4: MyServerInterface |
|
|
|
This is the server's user interface -- an applet.
In this example, the applet puts up a button.
When the user presses the button, the applet invokes the
|
|
Figure 5: MyServerApplet |
|
This applet has a handle to the remote server in the instance
variable When the button is pressed, the Since this applet is used as an attribute of the service,
it implements the |
To compile the example, run the c compile
script. This script places the output of the compile process in
2 separate run directories. The server-side
subdirectory launches the Jini service. The client-side
subdirectory launches the Jini client.
|
|
Figure 6: Compile Script |
|
|
|
by Noel Enete . . . www.enete.com . . . noel@enete.com |