/Users/lyon/j4p/src/graphics/raytracers/rmiRaytracer/raytracer/DoImageClient.java

1    //Created automatically CentiJ 
2    package graphics.raytracers.rmiRaytracer.raytracer; 
3     
4    import java.rmi.registry.LocateRegistry; 
5    import java.rmi.registry.Registry; 
6     
7    public class DoImageClient { 
8        private static String hosts[] = { 
9            //"192.168.1.94", 
10           //"192.168.1.96", 
11           "localhost" 
12    
13           //  "lyon.fairfield.edu", 
14       }; 
15       private static int diiIndex = 0; 
16       private static DoImageInterface dii[] = 
17               getDoImageInterfaces(hosts); 
18    
19    
20       public static DoImageInterface getNextInterface() { 
21           return dii[(diiIndex++) % dii.length]; 
22       } 
23    
24       static DoImageInterface[] getDoImageInterfaces(String hosts[]) { 
25           DoImageInterface dii[] = new 
26                   DoImageInterface[hosts.length]; 
27           for (int i = 0; i < hosts.length; i++) 
28               dii[i] = DoImageClient.getProxy(hosts[i]); 
29           return dii; 
30       } 
31    
32   // Example usage: 
33   // DoImageInterface di = DoImageClient.getProxy(); 
34       public static DoImageInterface getProxy( 
35               String host) { 
36           try { 
37               //locate the server class on remote machine 
38               Registry r = LocateRegistry.getRegistry(host); 
39               DoImageInterface rs = (DoImageInterface) r.lookup( 
40                       "DoImageServer"); 
41               return rs; 
42    
43           } catch (Exception e) { 
44               e.printStackTrace(); 
45           } 
46           return null; 
47    
48       } 
49    
50   }