Command-line invokable application launcher.
This launcher class assists in the creation of classloaders and
ClassRealm
s
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 String CLASSWORLDS_CONF
UBERJAR_CONF_DIR
protected static final String UBERJAR_CONF_DIR
mainClassName
protected String mainClassName
mainRealmName
protected String mainRealmName
systemClassLoader
protected ClassLoader systemClassLoader
getEnhancedMainMethod
protected Method getEnhancedMainMethod()
throws ClassNotFoundException,
NoSuchMethodException,
NoSuchRealmException
Retrieve the enhanced main entry method.
- The enhanced main entry method.
getExitCode
public int getExitCode()
getMainClass
public Class getMainClass()
throws ClassNotFoundException,
NoSuchRealmException
Retrieve the main entry class.
getMainClassName
public String getMainClassName()
getMainMethod
protected Method getMainMethod()
throws ClassNotFoundException,
NoSuchMethodException,
NoSuchRealmException
Retrieve the main entry method.
getMainRealmName
public String getMainRealmName()
getSystemClassLoader
public ClassLoader getSystemClassLoader()
launch
public void launch(String[] args)
throws ClassNotFoundException,
IllegalAccessException,
InvocationTargetException,
NoSuchMethodException,
NoSuchRealmException
Launch the application.
args
- The application args.
launchEnhanced
protected void launchEnhanced(String[] args)
throws ClassNotFoundException,
IllegalAccessException,
InvocationTargetException,
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.
launchStandard
protected void launchStandard(String[] args)
throws ClassNotFoundException,
IllegalAccessException,
InvocationTargetException,
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.
main
public static void main(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(String[] args)
throws Exception
Launch the launcher.
args
- The application command-line arguments.
setAppMain
public void setAppMain(String mainClassName,
String mainRealmName)
setSystemClassLoader
public void setSystemClassLoader(ClassLoader loader)