/Users/lyon/j4p/src/javassist/sample/rmi/StartComputationClient.java

1    package javassist.sample.rmi; 
2     
3    import javassist.web.Viewer; 
4     
5    /** 
6     * Created by  
7     * User: lyon 
8     * Date: Jan 25, 2004 
9     * Time: 5:47:16 PM 
10    *  
11    */ 
12   public class StartComputationClient { 
13       public static void main(String wow[]) { 
14           String args[] = { 
15               "localhost", 
16               "5500", 
17                "javassist.sample.rmi.ComputationClient" 
18           }; 
19           try { 
20               if (args.length >= 3) { 
21                   Viewer viewer = new Viewer(args[0], Integer.parseInt(args[1])); 
22                   String[] args2 = new String[args.length - 3]; 
23                   System.arraycopy(args, 3, args2, 0, args.length - 3); 
24                   String classname = args[2]; 
25                   Class c = viewer.loadClass(classname, false); 
26                   try { 
27                       c.getDeclaredMethod("main", new Class[]{String[].class}) 
28                               .invoke(null, new Object[]{args2}); 
29                   } catch (java.lang.reflect.InvocationTargetException e) { 
30                       throw e.getTargetException(); 
31                   } 
32               } else 
33                   System.err.println( 
34                           "Usage: java javassist.web.Viewer <host> <port> class [args ...]"); 
35           } catch (Throwable throwable) { 
36               throwable.printStackTrace(); 
37           } 
38       } 
39   } 
40