List of usage examples for com.google.gwt.dev WindowsExternalPermutationWorkerFactory CLASS_PATH_FILE_PROPERTY
String CLASS_PATH_FILE_PROPERTY
To view the source code for com.google.gwt.dev WindowsExternalPermutationWorkerFactory CLASS_PATH_FILE_PROPERTY.
Click Source Link
From source file:org.codehaus.mojo.gwt.shell.WindowsCommandLineLauncher.java
License:Apache License
public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, IOException, InstantiationException, NoSuchFieldException { //Extract arguments final String classPathFileName = args[0]; final String className = args[1]; final String[] additionalArguments = new String[args.length - 2]; for (int i = 2; i < args.length; i++) { additionalArguments[i - 2] = args[i]; }/*from w ww .j a va 2 s . co m*/ final File classPathFile = new File(classPathFileName); final List<URL> urls = new ArrayList<URL>(); //Copy in SystemClassLoader entries final String[] systemClassLoaderClassPath = ManagementFactory.getRuntimeMXBean().getClassPath() .split(File.pathSeparator); for (String classPathEntry : systemClassLoaderClassPath) { urls.add(new File(classPathEntry).toURI().toURL()); } //Read classpath from file final BufferedReader input = new BufferedReader(new FileReader(classPathFile)); try { String classPathEntry = null; while ((classPathEntry = input.readLine()) != null) { urls.add(new File(classPathEntry).toURI().toURL()); } } finally { input.close(); } //Set-up URLClassLoader using classpath extracted from the file. Null parent class-loader is important! final URL[] a = urls.toArray(new URL[urls.size()]); final ClassLoader loader = new URLClassLoader(a, null); //Setup new WorkerFactory System.setProperty(PermutationWorkerFactory.FACTORY_IMPL_PROPERTY, ThreadedPermutationWorkerFactory.class.getName() + "," + WindowsExternalPermutationWorkerFactory.class.getName()); //Record classpath file needed by com.google.gwt.dev.WindowsExternalPermutationWorkerFactory System.setProperty(WindowsExternalPermutationWorkerFactory.CLASS_PATH_FILE_PROPERTY, classPathFile.getAbsolutePath()); //Load real class final Class mainClass = loader.loadClass(className); //Invoke real class's main method Thread.currentThread().setContextClassLoader(loader); final Class mainMethodArgumentsType = String[].class; final Method mainMethod = mainClass.getMethod("main", new Class[] { mainMethodArgumentsType }); // this is SO UGLY... Field scl = ClassLoader.class.getDeclaredField("scl"); scl.setAccessible(true); scl.set(null, loader); // needed due to the possible Xerces conflicts as GWT uses system classloader to load these mainMethod.invoke(null, new Object[] { additionalArguments }); }