/** * 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() ); }
/** * Attempt to launch the application through the enhanced main method. * <p/> * <p/> * This will seek a method with the exact signature of: * </p> * <p/> * <pre> * public static void main(String[] args, ClassWorld world) * </pre> * * @throws ClassNotFoundException If the main entry class cannot be found. * @throws IllegalAccessException If the method cannot be accessed. * @throws java.lang.reflect.InvocationTargetException * If the target of the invokation is * invalid. * @throws NoSuchMethodException If the main entry method cannot be found. * @throws NoSuchRealmException If the main entry realm cannot be found. */ protected void launchX() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchRealmException { ClassRealm mainRealm = getMainRealm(); Class mainClass = getMainClass(); Method mainMethod = getEnhancedMainMethod(); Thread.currentThread().setContextClassLoader( mainRealm.getClassLoader() ); mainMethod.invoke( mainClass, new Object[]{getWorld()} ); }
throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException Method[] methods = getMainClass().getMethods();