Design Patterns Java™ Workbook

(Michael S) #1
Chapter 11. Proxy

Figure 11.5. To use RMI, you can define the interface you want for messages that pass
between computers and create a subclass of UnicastRemoteObject that implements it.


Your plan is for RocketImpl objects to be active on a server and to be available through a
proxy that is active on a client. The code for RocketImpl is simple:


package com.oozinoz.remote;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class RocketImpl
extends UnicastRemoteObject
implements Rocket
{
protected double price;
protected double apogee;


public RocketImpl(double price, double apogee)
throws RemoteException
{
this.price = price;
this.apogee = apogee;
}

Free download pdf