The Wayback Machine - https://web.archive.org/web/20160304054111/http://www.cs.rice.edu/~druschel/comp413/lectures/rmi-corba.html

Distributed Program Construction

Fall 1999

Lecture 5: RMI, CORBA



COMP 413
COMP 413
COMP 413Remote class hierarchy
 
COMP 413
package my_package;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class BankAccountImplextends UnicastRemoteObjectimplements BankAccount
{
   public void deposit (float amount) throws RemoteException {
                ...
   }
   public void withdraw (float amount) throws OverdrawnException,RemoteException {
                ...
  }
  public float balance() throws RemoteException {
                ...
        }
}

Invocation of Remote Methods


COMP 413
COMP 413
// serialize today's date to a file
FileOutputStream f = new FileOutputStream("tmp");
ObjectOutputStream  s  =  new  ObjectOutputStream(f);
s.writeObject("Today");
s.writeObject(new Date());
s.flush();

// Deserialize a string and date from a file.
FileInputStream in = new FileInputStream("tmp");
ObjectInputStream s = new ObjectInputStream(in);
String today = (String)s.readObject();
Date date = (Date)s.readObject();


COMP 413    1. Characteristics of a remote interface

COMP 413 import java.rmi.*;
  import java.rmi.server.UnicastRemoteObject;
 public class HelloImpl extends unicastRemoteObject implements Hello  {
  private String name;
  public HelloImpl(String s) throws RemoteException {
  super(); // just for clarity, java does it automatically
  name = s;
 }
 public String sayHello() throws RemoteException {
    return "Hello World";
 }
public static void main(String args[])
 {
   System.setSecurityManager(new RMISecurityManager());
    try {
      HelloImpl obj = new HelloImpl("HelloServer");
      Naming.rebind("//tochna11/HelloServer",Obj);
      System.out.println("HelloServer bounda in registry");
      } catch (Exception e) {
        System.out.println("HelloImpl err: " + e.getMessage());
        e.printStackTrace();
      }
    }
 } /* end of class */


COMP 413     import java.awt.*;
    impot java.rmi.*;
    public class HelloApplet extends java.applet.Applet
    {
     String message = "";
     public void init() {
     try {
          Hello obj = (Hello)Naming.lookup("//" +
                getCodeBase().getHost() + "/HelloServer")
                             message = obj.sayHello();
         } catch (Exception e) {
         System.out.println("HelloApplet Exception: " +
                             e.getMessage());
         e.printStrackTrace();
        }
    }
    public void paint(Graphics G) {
        g.drawString(message, 25, 50);
    }
   }
 
 


COMP 413
COMP 413Stub-skeleton Layer
COMP 413
COMP 413 Functions:Abstractions:



COMP 413
COMP 413   BankAccount acct = new BankAcctImpl();
   String url = "rmi://java.Sun.COM/account";
   // bind url to remote object
   java.rmi.Naming.bind(url, acct);
  ...
   // lookup account
   acct = (BankAccount)java.rmi.Naming.lookup(url);
COMP 413

CORBA

CORBA (Common Object Request Broker Architecture):

How does CORBA differ from RMI:
COMP 413










COMP 413

CORBA ORB Architecture
 
 



 
 
 
 


COMP 413

Development Process










COMP 413

CORBA IDL

Intro:


A nested namespace:

module services {
  interface inter1{
    long action();
  };
  interface inter2 {
    inter1 get_inter1();
  };
};

Parameter passing:Basic data types:Constants:
COMP 413

CORBA IDL (Cont.)

Type declarations:

struct car {
  string manufacturer;
  long velocity;
};

Arrays:

Exceptions:(Possibly multiple) inheritance of interfaces:The special type Any:
COMP 413
 
close