Chapter 4 |
||
Exporting an Object
There are two choices when creating a remote object:
Extend UnicastRemoteObject class, or The central theme of this chapter is how to explicitly export a remote object. The source code needed for this example is stored in the examples\Greater directory. The "Greater" directory contains the following files:
Server ArchitectureThe design of the server is simple. The server starts a registry service, registers itself with the registry, and exports a method. Creating Remote InterfaceThe GreaterInterface contains only one method that returns a string object. The getGreater() method compares two given numbers and returns the larger number. Listing 4.1 GreaterInterface.java (Complete code)import java.rmi.*; //server interface public interface GreaterInterface extends Remote{ //method used to compare two given numbers public String getGreater(int one,int two) throws RemoteException; } |
||
|
||
Copyright © 2001 www.universalteacher.com |
||