![]() ![]() ![]() |
|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
In this exercise you will build a client Applet that will act as both a RMI client and a server. Usually Applets only act as clients, however in some cases it makes sense for a server to make calls back into the applet. In this exercise the server will make periodic calls to the Applet and pass it the current date and time.
To support a callback, the Applet must act as an RMI server.
It does this by exporting and implementing a remote
interface.
Our Applet will define and implement the
The server cannot call back to the Applet until it knows where to find it.
It is the Applet's responsibility to register itself with the server.
It does this by using the server's
In this exercise, you will need to define the interfaces and the implementations for both the server and the Applet. RMI Client Side CallbacksSkeleton Code
Tasks
Define and compile the
Define and compile the
Complete the implementation for the method Complete the definition of the class TimeTicker.
Compile the server, RMIServer and create the Prepare the Applet for execution. Start the RMI Server in its own DOS console. Start the Applet with the appletviewer. Where help exists, the task numbers above are linked to the step-by-step help page. Solution Source
DemonstrationWhen the server is run in its DOS console, the output will be: Registry created Bindings Finished Waiting for Client requests Then when applet is run in its DOS console, the output will be: Exporting the Applet Looking up TimeService at: rmi://<your_computer_name>:10005/TimeServer We have been registered! The applet will appear in a window and start to display the current date and time every two seconds. Next MagerciseExercisesShort CourseCopyright 1996-2000 jGuru.com. All Rights Reserved. |