1 45 package org.exolab.jms.plugins.proxygen; 46 47 import java.net.URLClassLoader ; 48 import java.net.URL ; 49 import java.io.File ; 50 import java.io.FileNotFoundException ; 51 import java.util.StringTokenizer ; 52 53 54 60 public final class Main { 61 62 65 private Main() { 66 } 67 68 74 public static void main(String [] args) throws Exception { 75 if (args.length < 1 || args.length > 2) { 76 usage(); 77 System.exit(1); 78 } 79 String name = args[0]; 80 ClassLoader loader = Main.class.getClassLoader(); 81 82 if (args.length == 2) { 83 String classpath = args[1]; 84 StringTokenizer paths = new StringTokenizer ( 85 classpath, File.pathSeparator); 86 URL [] urls = new URL [paths.countTokens()]; 87 for (int i = 0; i < urls.length; ++i) { 88 File file = new File (paths.nextToken()); 89 if (!file.exists()) { 90 throw new FileNotFoundException (file.getPath()); 91 } 92 urls[i] = file.getCanonicalFile().toURL(); 93 } 94 loader = new URLClassLoader (urls); 95 } 96 Class clazz = loader.loadClass(name); 97 ProxyGenerator generator = new ProxyGenerator(clazz, null); 98 generator.generate(System.out); 99 } 100 101 104 private static void usage() { 105 System.err.println("usage: " + Main.class.getName() 106 + " <classname> [classpath]"); 107 } 108 109 } 110 | Popular Tags |