public interface BankAccountextends Remote { public void deposit (float amount) throws java.rmi.RemoteException; public void withdraw (float amount) throws OverdrawnException, java.rmi.RemoteException; public float balance() throws java.rmi.RemoteException; } |
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
try {
BankAccount acct = (BankAccount)java.rmi.Naming.lookup(url);
balance = acct.balance();
} catch (Exception e) {
System.out.println("Bank exception: " +e.getMessage());
e.printStackTrace();
}
// 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. |
<HTML> <title>Hello World</title> <center> <h1> Hello World</h1> </center> The message from the HelloServer is: |
CORBA
CORBA (Common Object Request Broker Architecture):
CORBA ORB Architecture
Development Process
CORBA IDL
Intro:
A nested namespace:
module services {
interface inter1{
long action();
};
interface inter2 {
inter1 get_inter1();
};
};
CORBA IDL (Cont.)
Type declarations:
Arrays:
typedef long[10] my_array;