IBM User Guide for Java V7 on Windows > IBM SDK for Java > The ORB > Examples of client–server applications



Remote object implementation (or servant)

This description shows possible implementations of the object.

The possible RMI(JRMP) and RMI-IIOP implementations (SampleImpl.java) of this object could be:

 public class SampleImpl extends javax.rmi.PortableRemoteObject implements Sample { 	
       public SampleImpl() throws java.rmi.RemoteException { super(); }  
      	public String message() { return "Hello World!"; } }

You can use the class PortableRemoteObject for both RMI over JRMP and IIOP. The effect is to make development of the remote object effectively independent of the protocol that is used. The object implementation does not need to extend PortableRemoteObject, especially if it already extends another class (single-class inheritance). Instead, the remote object instance must be exported in the server implementation. Exporting a remote object makes the object available to accept incoming remote method requests. When you extend javax.rmi.PortableRemoteObject, your class is exported automatically on creation.

The CORBA or Java™ IDL implementation of the remote object (servant) is:

public class SampleImpl extends _SamplePOA {     
    public String message() { return "Hello World"; } }
The POA is the Portable Object Adapter, described in Portable object adapter.

The implementation conforms to the Inheritance model, in which the servant extends directly the IDL-generated skeleton SamplePOA. You might want to use the Tie or Delegate model instead of the typical Inheritance model if your implementation must inherit from some other implementation. In the Tie model, the servant implements the IDL-generated operations interface (such as SampleOperations). The Tie model introduces a level of indirection, so that one extra method call occurs when you invoke a method. The server code describes the extra work that is required in the Tie model, so that you can decide whether to use the Tie or the Delegate model. In RMI-IIOP, you can use only the Tie or Delegate model.


Parent: Examples of client–server applications








Error 404 - Not Found

Error 404 - Not Found

The document you are looking for may have been removed or re-named. Please contact the web site owner for further assistance.