Java Reference
In-Depth Information
The choice is rather arbitrary and personal. If a different scheme than that shown
here is desired, just be sure to modify the package statements, subdirectories, and
import statements accordingly.
// RMIExampleImpl.java
package javatech.rmi18.server.impl;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import javatech.rmi18.server.*;
// location of the interface classes
/** The implementation class that implements the remote
* methods declared in the <tt>RMIExampleInterface</tt>
* interface. **/
public class RMIExampleImpl
extends UnicastRemoteObject
implements RMIExampleInterface
{
// The default constructor will not work since
// UnicastRemoteObject, which we extend,
// throws RemoteException, which the default
// constructor provided by the compiler does not.
// Therefore, we must implement a default constructor
// that throws RemoteException even if the
// constructor does nothing at all. It will, of course,
// automatically call its superclass constructor.
/** Constructor.Must throw <tt>RemoteException</tt>. **/
public RMIExampleImpl () throws RemoteException {}
/** Echoes the input string provided by the client. **/
public void method1 (String s) {
System.out.println ("RMIExampleImpl.method1: " + s);
} // method1
/** Adds the input parameters and returns the sum. **/
public int add (int a, int b) {
System.out.println (
" RMIExampleImpl.add: computing sum of " +
a+ " and " + b);
returna+b;
} // add
 
Search WWH ::




Custom Search