1 7 package org.ejtools.management.browser; 8 9 import java.beans.Beans ; 10 import java.io.File ; 11 import java.net.URL ; 12 import java.net.URLClassLoader ; 13 import java.security.AccessController ; 14 import java.security.Permission ; 15 import java.security.PrivilegedExceptionAction ; 16 import java.util.LinkedList ; 17 18 import org.apache.log4j.Logger; 19 20 27 public class Main 28 { 29 30 private static Logger logger = Logger.getLogger(Main.class); 31 32 33 39 public static void main(String [] args) 40 throws Exception 41 { 42 logger.debug("========================================"); 43 logger.debug("JAVA_HOME : " + System.getProperty("java.home")); 44 logger.debug("Vendor : " + System.getProperty("java.vendor")); 45 logger.debug("Version : " + System.getProperty("java.version")); 46 logger.debug("Operating Sys. : " + System.getProperty("os.name")); 47 logger.debug("Architecture : " + System.getProperty("os.arch")); 48 logger.debug("Version : " + System.getProperty("os.version")); 49 logger.debug("========================================"); 50 51 File pluginDir; 52 File [] plugins; 53 LinkedList list = new LinkedList (); 54 55 logger.debug("Building classpath..."); 56 57 logger.debug("Scanning lib directory..."); 59 pluginDir = new File ("../lib"); 60 plugins = pluginDir.listFiles(); 61 if (plugins != null) 62 { 63 for (int i = 0; i < plugins.length; i++) 64 { 65 logger.debug("Found " + plugins[i].toURL()); 66 list.add(plugins[i].toURL()); 67 } 68 } 69 70 logger.debug("Scanning lib/ext directory..."); 72 pluginDir = new File ("../lib/ext"); 73 plugins = pluginDir.listFiles(); 74 if (plugins != null) 75 { 76 for (int i = 0; i < plugins.length; i++) 77 { 78 logger.debug("Found " + plugins[i].toURL()); 79 list.add(plugins[i].toURL()); 80 } 81 } 82 logger.debug("========================================"); 83 84 URL [] pluginURLs = (URL []) list.toArray(new URL [list.size()]); 86 Thread.currentThread().setContextClassLoader( 87 new URLClassLoader (pluginURLs, Thread.currentThread().getContextClassLoader()) 88 ); 89 90 System.setSecurityManager( 92 new SecurityManager () 93 { 94 public void checkPermission(Permission p) { } 95 96 97 public void checkPermission(Permission perm, Object context) { } 98 }); 99 100 logger.debug("Launching EJTools Management Browser"); 102 AccessController.doPrivileged( 103 new PrivilegedExceptionAction () 104 { 105 public Object run() 106 throws Exception 107 { 108 Beans.instantiate( 109 Thread.currentThread().getContextClassLoader(), 110 "org.ejtools.management.browser.Browser" 111 ); 112 return null; 113 } 114 }); 115 } 116 } 117 118 | Popular Tags |