Defining the Remote Interface

Listing 13.1 LazyInterface.java

 

import java.rmi.*;

//remote interface
public interface LazyInterface extends Remote {

  //method called by clients
  public String sayHello() throws RemoteException;
}

The LazyInterface declares a method that returns "Hello World" to the caller.

 

Implementation of Remote Interface

An activatable object is defined by:

  • Subclassing the object implementation from the java.rmi.activation.Activatable class.
  • Providing activation constructors in the server implementation
  • Registering the object with the activation service.

If an object is not active and a method is invoked, the activation system activates the object using the activation protocol. After the object has been activated, the method invocation takes place and the result is marshaled to the client.

In this example, the server class (LazyServerImpl) will implement the remote interface (LazyInterface) and extend Activatable.

Figure 13.1

 

 

 

RMI BOOK MAIN PAGE                Top

  
Copyright © 2001 www.universalteacher.com