1 22 23 package org.aspectj.debugger.ide; 24 25 public class Main { 26 27 34 SourceShower getShower() { 35 if (shower != null) { 36 try { 37 return (SourceShower) Class.forName(shower).newInstance(); 38 } catch (Throwable t) { 39 t.printStackTrace(); 40 } 41 } 42 return FullPathSourceShower.proto; 43 } 44 45 IDEInterface getIDE() { 46 if (ide != null) { 47 try { 48 IDEInterface i = (IDEInterface) Class.forName(ide).newInstance(); 49 System.out.println("i:" + i); 50 return i; 51 } catch (Throwable t) { 52 t.printStackTrace(); 53 } 54 } 55 return null; 56 } 57 58 String mainClass; 59 String classPath; 60 String sourcePath; 61 String mode; 62 String shower; 63 String ide; 64 boolean verbose = false; 65 66 public static void main(String [] args) { 67 new Main().realMain(args); 68 } 69 70 71 public void realMain(String [] args) { 72 parseArgs(args); 73 IDEDebugger.launch(mainClass, sourcePath, classPath, mode, new String [0], getShower(), getIDE()); 74 } 75 76 void parseArgs(String [] args) { 77 String arg = ""; 78 String val = ""; 79 for (int i = 0; i < args.length; i++) { 80 arg = args[i]; 81 if (arg.equals("-mainclass")) { 82 if (check("mainclass", args, i)) mainClass = args[++i]; 83 } else if (arg.equals("-classpath")) { 84 if (check("classpath", args, i)) classPath = args[++i]; 85 } else if (arg.equals("-sourcepath")) { 86 if (check("sourcepath", args, i)) sourcePath = args[++i]; 87 } else if (arg.equals("-mode")) { 88 if (check("mode", args, i)) mode = args[++i]; 89 } else if (arg.equals("-shower")) { 90 if (check("shower", args, i)) shower = args[++i]; 91 } else if (arg.equals("-ide")) { 92 if (check("ide", args, i)) ide = args[++i]; 93 } else if (arg.equals("-verbose")) { 94 verbose = true; 95 } 96 } 97 } 98 99 boolean check(String arg, String [] args, int i) { 100 if (args == null || args.length < i || args[i+1] == null) { 101 exit("bad argument to " + arg + " i=" + i + " length=" + args.length); 102 return false; 103 } 104 return true; 105 } 106 107 void exit(String msg) { 108 System.err.println(msg); 109 System.exit(1); 110 } 111 } 112 | Popular Tags |