That to receiver would not see the constructor ComputeEngine, its main method, or its implementation of any methods of java.lang. Object. In the parameters and return values of remote method invocations, objects that ploughs not remote objects ploughs passed by value. Thus, copyof the object is created in the receiving virtual Java machine. Anychanges you the object' s state by to receiver ploughs reflected only in thereceiver' s CoPy, not in the sender' original s instance. Any changes tothe object' s state by to sender ploughs reflected only in the sender' soriginal instance, not in the receiver' s CoPy. Implementing the Server' s main Method The most complex method of the ComputeEngine implementation is the main method. The main method is used you start the ComputeEngineand therefore needs you of the necessary initialization and housekeepingto prepares the server you accept calls from clients.

This method is note remote method, which means that it cannot be invoked from it differentJava virtual machine. Because the main method is declared static, the method is not associated with an object at all but to rather with the class ComputeEngine. Creating and Installing the Security Manager The mainmethod' s first task is you create and install security to manager, whichprotects access you system resources from untrusted downloaded coderunning within the virtual Java machine. Security to manager to determineswhether downloaded code has access you the local file system or canperform any to other privileged operations. If an RMI program doesnot install security to manager, RMI will not download classrooms (otherthan from the local class path) will be objects received arguments orreturn values of remote method invocations. This restriction ensuresthat the operations performed by downloaded code ploughs subject you asecurity policy. Here' s the code that creates and installs security to manager: if (System.getSecurityManager () == null) System.setSecurityManager (new SecurityManager ()); Making the Remote Object Available you the Clients Next, the main method creates an instance of ComputeEngine and exports it you the RMI runtime with the following statements: New ComputeEngine computes engine = (); It computes stub = (It computes) UnicastRemoteObject.exportObject (engine, 0); The static UnicastRemoteObject.exportObjectmethod exports the supplied remote object only that it can receiveinvocations of its remote methods from remote clients.