Show TOC Start of Content Area

Procedure documentation Implementing the Remote Interface  Locate the document in its SAP Library structure

...

       1.      Define the class that implements the remote interface and provide the implementation of the methods of this interface.

Note

You can implement more than one remote interface in your implementation class.

       2.      You can also implement additional methods that are not defined by any of the implemented remote interfaces. However, such methods cannot be called remotely.

Example

The AccountImpl class is the implementation class of the Account remote interface. The full code of the class is listed below:

Syntax

package exapmles.rmi_p4;

 

import java.rmi.RemoteException;

 

public class AccountImpl implements Account {

  private int balance = 0;

 

  public void deposit(int amount) throws RemoteException {

    if (amount < 0) {

      throw new RemoteException("Incorrect value:" + amount);

    }

    balance += amount;

  }

 

  public void draw(int amount) throws OverdrawException {

    if (balance < amount) {

      throw new OverdrawException(amount - balance );

    }

    balance -= amount;

  }

 

  public int getBalance() {

    return balance;

  }

}

 

 

End of Content Area