Command-line invokable application launcher.
This launcher class assists in the creation of classloaders and
ClassRealms
from a configuration file and the launching of the application's
main
method from the correct class loaded through the correct classloader.
The path to the configuration file is specified using the
classworlds.conf
system property, typically specified using the
-D switch to
java.
CLASSWORLDS_CONF
protected static final java.lang.String CLASSWORLDS_CONF
UBERJAR_CONF_DIR
protected static final java.lang.String UBERJAR_CONF_DIR
mainClassName
protected java.lang.String mainClassName
mainRealmName
protected java.lang.String mainRealmName
systemClassLoader
protected java.lang.ClassLoader systemClassLoader
getEnhancedMainMethod
protected java.lang.reflect.Method getEnhancedMainMethod()
throws java.lang.ClassNotFoundException,
java.lang.NoSuchMethodException,
NoSuchRealmException Retrieve the enhanced main entry method.
- The enhanced main entry method.
getExitCode
public int getExitCode()
getMainClass
public java.lang.Class getMainClass()
throws java.lang.ClassNotFoundException,
NoSuchRealmException Retrieve the main entry class.
getMainClassName
public java.lang.String getMainClassName()
getMainMethod
protected java.lang.reflect.Method getMainMethod()
throws java.lang.ClassNotFoundException,
java.lang.NoSuchMethodException,
NoSuchRealmException Retrieve the main entry method.
getMainRealmName
public java.lang.String getMainRealmName()
getSystemClassLoader
public java.lang.ClassLoader getSystemClassLoader()
launch
public void launch(java.lang.String[] args)
throws java.lang.ClassNotFoundException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.lang.NoSuchMethodException,
NoSuchRealmException Launch the application.
args - The application args.
java.lang.reflect.InvocationTargetException - If the target of the invokation is invalid.NoSuchRealmException - If the main entry realm cannot be found.
launchEnhanced
protected void launchEnhanced(java.lang.String[] args)
throws java.lang.ClassNotFoundException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.lang.NoSuchMethodException,
NoSuchRealmException Attempt to launch the application through the enhanced main method.
This will seek a method with the exact signature of:
public static void main(String[] args, ClassWorld world)
args - The application args.
java.lang.reflect.InvocationTargetException - If the target of the invokation is
invalid.NoSuchRealmException - If the main entry realm cannot be found.
launchStandard
protected void launchStandard(java.lang.String[] args)
throws java.lang.ClassNotFoundException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException,
java.lang.NoSuchMethodException,
NoSuchRealmException Attempt to launch the application through the standard main method.
This will seek a method with the exact signature of:
public static void main(String[] args)
args - The application args.
java.lang.reflect.InvocationTargetException - If the target of the invokation is
invalid.NoSuchRealmException - If the main entry realm cannot be found.
main
public static void main(java.lang.String[] args)
Launch the launcher from the command line.
Will exit using System.exit with an exit code of 0 for success, 100 if there was an unknown exception,
or some other code for an application error.
args - The application command-line arguments.
mainWithExitCode
public static int mainWithExitCode(java.lang.String[] args)
throws java.lang.Exception Launch the launcher.
args - The application command-line arguments.
java.lang.Exception - If an error occurs.
setAppMain
public void setAppMain(java.lang.String mainClassName,
java.lang.String mainRealmName)
setSystemClassLoader
public void setSystemClassLoader(java.lang.ClassLoader loader)