package edu.gac.max.movies.dummy; import java.rmi.Naming; import java.rmi.RemoteException; import java.rmi.UnexpectedException; import java.rmi.RMISecurityManager; import java.rmi.server.UnicastRemoteObject; import java.sql.Connection; import edu.gac.max.movies.Chain; import edu.gac.max.movies.Store; public class ChainImpl extends UnicastRemoteObject implements Chain { private Connection con; // maybe some other state, like a prepared statement public ChainImpl() throws RemoteException { con = null; // in a non-dummy version, would get real one } public Store[] getStores() throws RemoteException { java.util.Vector v = new java.util.Vector(); // a real one would use the database to identify stores v.addElement(new StoreImpl(con, "St. Peter", 1)); v.addElement(new StoreImpl(con, "Mankato", 2)); Store[] array = new Store[v.size()]; v.copyInto(array); return array; } public static void main(String args[]) { if (System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } try { ChainImpl obj = new ChainImpl(); Naming.rebind("/max-dummy-chain", obj); } catch (Exception e) { System.out.println("ChainImpl err: " + e.getMessage()); e.printStackTrace(); } } }