//Created automatically CentiJ
package graphics.raytracer;

import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

public class DoImageClient {
  private static String hosts[] = {
    //"192.168.1.94",
    //"192.168.1.96",
    "localhost"

    //  "lyon.fairfield.edu",
  };
  private static int diiIndex = 0;
  private static DoImageInterface dii[] =
      getDoImageInterfaces(hosts);


  public static DoImageInterface getNextInterface() {
    return dii[(diiIndex++) % dii.length];
  }

  static DoImageInterface[] getDoImageInterfaces(String hosts[]) {
    DoImageInterface dii[] = new
        DoImageInterface[hosts.length];
    for (int i = 0; i < hosts.length; i++)
      dii[i] = DoImageClient.getProxy(hosts[i]);
    return dii;
  }

// Example usage:
// DoImageInterface di = DoImageClient.getProxy();
  public static DoImageInterface getProxy(
      String host) {
    try {
      //locate the server class on remote machine
      Registry r = LocateRegistry.getRegistry(host);
      DoImageInterface rs = (DoImageInterface) r.lookup(
          "DoImageServer");
      return rs;

    } catch (Exception e) {
      e.printStackTrace();
    }
    return null;

  }

}