1 12 13 package org.ejtools.jmx.browser; 14 15 16 17 import java.beans.Beans ; 18 19 import java.io.File ; 20 21 import java.net.URL ; 22 23 import java.net.URLClassLoader ; 24 25 import java.security.AccessController ; 26 27 import java.security.Permission ; 28 29 import java.security.PrivilegedExceptionAction ; 30 31 import java.util.LinkedList ; 32 33 34 35 import org.apache.log4j.Logger; 36 37 38 39 52 53 public class Main { 54 55 56 57 private static Logger logger = Logger.getLogger(Main.class); 58 59 60 61 62 63 74 75 public static void main(String [] args) 76 77 throws Exception { 78 79 logger.debug("========================================"); 80 81 logger.debug("JAVA_HOME : " + System.getProperty("java.home")); 82 83 logger.debug("Vendor : " + System.getProperty("java.vendor")); 84 85 logger.debug("Version : " + System.getProperty("java.version")); 86 87 logger.debug("Operating Sys. : " + System.getProperty("os.name")); 88 89 logger.debug("Architecture : " + System.getProperty("os.arch")); 90 91 logger.debug("Version : " + System.getProperty("os.version")); 92 93 logger.debug("========================================"); 94 95 96 97 File pluginDir; 98 99 File [] plugins; 100 101 LinkedList list = new LinkedList (); 102 103 104 105 logger.debug("Building classpath..."); 106 107 108 109 111 logger.debug("Scanning lib directory..."); 112 113 pluginDir = new File ("../lib"); 114 115 plugins = pluginDir.listFiles(); 116 117 if (plugins != null) { 118 119 for (int i = 0; i < plugins.length; i++) { 120 121 logger.debug("Found " + plugins[i].toURL()); 122 123 list.add(plugins[i].toURL()); 124 125 } 126 127 } 128 129 130 131 133 logger.debug("Scanning lib/ext directory..."); 134 135 pluginDir = new File ("../lib/ext"); 136 137 plugins = pluginDir.listFiles(); 138 139 if (plugins != null) { 140 141 for (int i = 0; i < plugins.length; i++) { 142 143 logger.debug("Found " + plugins[i].toURL()); 144 145 list.add(plugins[i].toURL()); 146 147 } 148 149 } 150 151 logger.debug("========================================"); 152 153 154 155 157 URL [] pluginURLs = (URL []) list.toArray(new URL [list.size()]); 158 159 Thread.currentThread().setContextClassLoader( 160 161 new URLClassLoader (pluginURLs, Thread.currentThread().getContextClassLoader()) 162 163 ); 164 165 166 167 169 System.setSecurityManager( 170 171 new SecurityManager () { 172 173 public void checkPermission(Permission p) { } 174 175 176 177 178 179 public void checkPermission(Permission perm, Object context) { } 180 181 }); 182 183 184 185 187 logger.debug("Launching EJTools JMX Browser"); 188 189 AccessController.doPrivileged( 190 191 new PrivilegedExceptionAction () { 192 193 public Object run() 194 195 throws Exception { 196 197 Beans.instantiate( 198 199 Thread.currentThread().getContextClassLoader(), 200 201 "org.ejtools.jmx.browser.Browser" 202 203 ); 204 205 return null; 206 207 } 208 209 }); 210 211 } 212 213 } 214 215 216 217 | Popular Tags |