InvocationTargetException, NoSuchMethodException, NoSuchRealmException ClassRealm mainRealm = getMainRealm(); Class mainClass = getMainClass(); Method mainMethod = getEnhancedMainMethod(); getWorld()});
/** * Retrieve the main entry class. * * @return The main entry class. * @throws ClassNotFoundException If the class cannot be found. * @throws NoSuchRealmException If the specified main entry realm does not exist. */ public Class getMainClass() throws ClassNotFoundException, NoSuchRealmException { return getMainRealm().loadClass( getMainClassName() ); }
/** * Retrieve the main entry realm. * * @return The main entry realm. * @throws NoSuchRealmException If the specified main entry realm does not exist. */ public ClassRealm getMainRealm() throws NoSuchRealmException { return getWorld().getRealm( getMainRealmName() ); }
Launcher launcher = new Launcher(); launcher.setSystemClassLoader( cl ); launcher.configure( is ); launcher.launch( args ); ClassRealm realm = launcher.getWorld().getRealm( launcher.getMainRealmName() ); return launcher.getExitCode();
launcher = new Launcher(); launcher.setSystemClassLoader(Main.class.getClassLoader()); launcher.configure(Main.class.getResourceAsStream( is206OrLater?"classworlds-2.0.6.conf":"classworlds.conf")); ClassRealm remoting = new DefaultClassRealm(launcher.getWorld(),"hudson-remoting", launcher.getSystemClassLoader()); remoting.setParent(launcher.getWorld().getRealm("plexus.core.maven")); remoting.addConstituent(remotingJar.toURI().toURL());
/** * Called by the code in remoting to launch. * @throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException */ public static int launch(String[] args) throws NoSuchMethodException, IllegalAccessException, NoSuchRealmException, InvocationTargetException, ClassNotFoundException { //ClassWorld world = ClassWorldAdapter.getInstance( launcher.getWorld() ); ClassWorld world = launcher.getWorld(); Set builtinRealms = new HashSet(world.getRealms()); try { launcher.launch(args); } finally { // delete all realms created by Maven // this is because Maven creates a child realm for each plugin it loads, // and the realm id doesn't include the version. // so unless we discard all the realms multiple invocations // that use different versions of the same plugin will fail to work correctly. Set all = new HashSet(world.getRealms()); all.removeAll(builtinRealms); for (Iterator itr = all.iterator(); itr.hasNext();) { ClassRealm cr = (ClassRealm) itr.next(); world.disposeRealm(cr.getId()); } } return launcher.getExitCode(); } }
InvocationTargetException, NoSuchMethodException, NoSuchRealmException ClassRealm mainRealm = getMainRealm(); Class mainClass = getMainClass(); Method mainMethod = getMainMethod();
if ( this.launcher != null ) foreignClassLoader = this.launcher.getSystemClassLoader(); this.launcher.setAppMain( mainClassName, mainRealmName ); if ( this.launcher != null ) this.launcher.setWorld( world );
/** * Retrieve the enhanced main entry method. * * @return The enhanced main entry method. * @throws ClassNotFoundException If the main entry class cannot be found. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ protected Method getEnhancedMainMethod() throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException { Method[] methods = getMainClass().getMethods(); Class cwClass = getMainRealm().loadClass( ClassWorld.class.getName() ); Method m = getMainClass().getMethod( "main", new Class[] { String[].class, cwClass } ); int modifiers = m.getModifiers(); if ( Modifier.isStatic( modifiers ) && Modifier.isPublic( modifiers ) ) { if ( m.getReturnType() == Integer.TYPE || m.getReturnType() == Void.TYPE ) { return m; } } throw new NoSuchMethodException( "public static void main(String[] args, ClassWorld world)" ); }
/** * Retrieve the main entry method. * * @return The main entry method. * @throws ClassNotFoundException If the main entry class cannot be found. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ protected Method getMainMethod() throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException { Method m = getMainClass().getMethod( "main", new Class[] { String[].class } ); int modifiers = m.getModifiers(); if ( Modifier.isStatic( modifiers ) && Modifier.isPublic( modifiers ) ) { if ( m.getReturnType() == Integer.TYPE || m.getReturnType() == Void.TYPE ) { return m; } } throw new NoSuchMethodException( "public static void main(String[] args) in " + getMainClass() ); }
launcher = new Launcher(); launcher.setSystemClassLoader(Main.class.getClassLoader()); launcher.configure(Main.class.getResourceAsStream( is206OrLater?"classworlds-2.0.6.conf":"classworlds.conf")); ClassRealm remoting = new DefaultClassRealm(launcher.getWorld(),"hudson-remoting", launcher.getSystemClassLoader()); remoting.setParent(launcher.getWorld().getRealm("plexus.core.maven")); remoting.addConstituent(remotingJar.toURI().toURL());
/** * Called by the code in remoting to launch. * @throws org.codehaus.plexus.classworlds.realm.NoSuchRealmException */ public static int launch(String[] args) throws NoSuchMethodException, IllegalAccessException, NoSuchRealmException, InvocationTargetException, ClassNotFoundException { //ClassWorld world = ClassWorldAdapter.getInstance( launcher.getWorld() ); ClassWorld world = launcher.getWorld(); Set builtinRealms = new HashSet(world.getRealms()); try { launcher.launch(args); } finally { // delete all realms created by Maven // this is because Maven creates a child realm for each plugin it loads, // and the realm id doesn't include the version. // so unless we discard all the realms multiple invocations // that use different versions of the same plugin will fail to work correctly. Set all = new HashSet(world.getRealms()); all.removeAll(builtinRealms); for (Iterator itr = all.iterator(); itr.hasNext();) { ClassRealm cr = (ClassRealm) itr.next(); world.disposeRealm(cr.getId()); } } return launcher.getExitCode(); } }
/** Retrieve the main entry realm. * * @return The main entry realm. * * @throws NoSuchRealmException If the specified main entry realm does not exist. */ public ClassRealm getMainRealm() throws NoSuchRealmException { return getWorld().getRealm(getMainRealmName()); }
InvocationTargetException, NoSuchMethodException, NoSuchRealmException ClassRealm mainRealm = getMainRealm(); Class mainClass = getMainClass(); Method mainMethod = getMainMethod();
throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException Method[] methods = getMainClass().getMethods(); throw new NoSuchMethodException("public static void main(String[] args) in " + getMainClass() );
InvocationTargetException, NoSuchMethodException, NoSuchRealmException ClassRealm mainRealm = getMainRealm(); Class mainClass = getMainClass(); Method mainMethod = getEnhancedMainMethod(); Object ret = mainMethod.invoke( mainClass, new Object[]{args, getWorld()} ); if ( ret instanceof Integer )
/** Retrieve the main entry class. * * @return The main entry class. * * @throws ClassNotFoundException If the class cannot be found. * @throws NoSuchRealmException If the specified main entry realm does not exist. */ public Class getMainClass() throws ClassNotFoundException, NoSuchRealmException { return getMainRealm().loadClass(getMainClassName()); }
throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException Method[] methods = getMainClass().getMethods();