Show TOC Start of Content Area

Object documentation Characteristics of a Remote Object  Locate the document in its SAP Library structure

Definition

A remote object is an object that defines methods that can be called by a client located in a remote Java Virtual Machine (JVM). A remote object implements one or more remote interfaces that declare remote methods of the object.

Use

Consider the following guidelines when you implement the remote interface inherited by the remote object:

·        The implementation class can implement one or more remote interfaces.

·        The implementation class can inherit other remote objects.

·        The implementation class can declare methods that are not declared by a remote object; those methods can be called locally only.

Structure

Remote Interfaces and Classes

From RMI-P4 perspective, a remote interface is any interface that inherits the java.rmi.Remoteinterface, either directly or indirectly. Each method that such an interface or its superior interfaces define is considered a remote method.

Example

The following remote interface directly inherits java.rmi.Remote, and defines three remote methods:

public interface Account extends java.rmi.Remote {

    public void deposit(int amount);

    public void draw (int amount) throws OverdrawException;

   public int getBalance() throws java.rmi.RemoteException;

}

Note

According to the RMI-P4 definition of a remote method, it is not mandatory to throw java.rmi.RemoteException (as opposed to the RMI specification that requires remote objects to throw such an exception). However, we recommend that you declare RemoteException in the throw clauses of your remote methods for the sake of consistency in exception handling. Also, this avoids the possibility of getting a com.sap.engine.services.rmi_p4.P4RuntimeException exception when the methods are executed.

Example

A remote interface can inherit both a non-remote interface and a java.rmi.Remoteinterface.

Assume we have the following interface:

public interface Parent {

  public void method1();

  public void method2() throws java.rmi.RemoteException;

  public void method3() throws UserException;

}

The following interface inherits the Parent interface, along with the java.rmi.Remote:

public interface Child extends Parent, java.rmi.Remote {

}

According to the rule above, all the methods of the Parent interface are valid remote methods.

Parameters Transmitted by Remote Objects

A parameter that is sent to or returned from a remote object can be any serializable object. These are the primitive Java types, the remote objects, and non-remote objects that implement java.io.Serializable.

 

End of Content Area