1 7 package net.sourceforge.ejtools.management.test; 8 9 import java.io.File ; 10 import java.net.URL ; 11 import java.net.URLClassLoader ; 12 import java.security.AccessController ; 13 import java.security.Permission ; 14 import java.security.PrivilegedExceptionAction ; 15 import java.util.LinkedList ; 16 17 23 public class Main 24 { 25 31 public static void main(String [] args) throws Exception 32 { 33 File pluginDir = new File ("../lib/ext"); 34 LinkedList list = new LinkedList (); 35 File [] plugins = pluginDir.listFiles(); 36 for (int i = 0; i < plugins.length; i++) 37 { 38 System.out.println(plugins[i].toURL()); 39 list.add(plugins[i].toURL()); 40 } 41 pluginDir = new File ("../lib"); 42 plugins = pluginDir.listFiles(); 43 for (int i = 0; i < plugins.length; i++) 44 { 45 System.out.println(plugins[i].toURL()); 46 list.add(plugins[i].toURL()); 47 } 48 URL [] pluginURLs = (URL []) list.toArray(new URL [list.size()]); 49 50 Thread.currentThread().setContextClassLoader(new URLClassLoader (pluginURLs, Thread.currentThread().getContextClassLoader())); 51 System.setSecurityManager( 52 new SecurityManager () 53 { 54 public void checkPermission(Permission p) { } 55 56 57 public void checkPermission(Permission perm, Object context) { } 58 }); 59 60 File resultDir = new File ("../report/xml"); 62 if (!resultDir.exists()) 63 { 64 resultDir.mkdirs(); 65 } 66 67 AccessController.doPrivileged( 69 new PrivilegedExceptionAction () 70 { 71 public Object run() 72 throws Exception 73 { 74 java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(), "net.sourceforge.ejtools.management.test.ManagementTestRunner"); 75 return null; 76 } 77 }); 78 79 } 80 } 81 82 | Popular Tags |