public class Launcher extends Object
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
.
Modifier and Type | Field and Description |
---|---|
protected static String |
CLASSWORLDS_CONF |
protected String |
mainClassName |
protected String |
mainRealmName |
protected ClassLoader |
systemClassLoader |
protected static String |
UBERJAR_CONF_DIR |
protected ClassWorld |
world |
Constructor and Description |
---|
Launcher() |
Modifier and Type | Method and Description |
---|---|
void |
configure(InputStream is)
Configure from a file.
|
protected Method |
getEnhancedMainMethod()
Retrieve the enhanced main entry method.
|
int |
getExitCode() |
Class<?> |
getMainClass()
Retrieve the main entry class.
|
String |
getMainClassName() |
protected Method |
getMainMethod()
Retrieve the main entry method.
|
ClassRealm |
getMainRealm()
Retrieve the main entry realm.
|
String |
getMainRealmName() |
ClassLoader |
getSystemClassLoader() |
ClassWorld |
getWorld() |
void |
launch(String[] args)
Launch the application.
|
protected void |
launchEnhanced(String[] args)
Attempt to launch the application through the enhanced main method.
|
protected void |
launchStandard(String[] args)
Attempt to launch the application through the standard main method.
|
static void |
main(String[] args)
Launch the launcher from the command line.
|
static int |
mainWithExitCode(String[] args)
Launch the launcher.
|
void |
setAppMain(String mainClassName,
String mainRealmName) |
void |
setSystemClassLoader(ClassLoader loader) |
void |
setWorld(ClassWorld world) |
protected static final String CLASSWORLDS_CONF
protected static final String UBERJAR_CONF_DIR
protected ClassLoader systemClassLoader
protected String mainClassName
protected String mainRealmName
protected ClassWorld world
public void setSystemClassLoader(ClassLoader loader)
public ClassLoader getSystemClassLoader()
public int getExitCode()
public String getMainRealmName()
public String getMainClassName()
public void setWorld(ClassWorld world)
public ClassWorld getWorld()
public void configure(InputStream is) throws IOException, ConfigurationException, DuplicateRealmException, NoSuchRealmException
is
- The config input stream.IOException
- If an error occurs reading the config file.MalformedURLException
- If the config file contains invalid URLs.ConfigurationException
- If the config file is corrupt.DuplicateRealmException
- If the config file defines two realms
with the same id.NoSuchRealmException
- If the config file defines a main entry
point in a non-existent realm.public Class<?> getMainClass() throws ClassNotFoundException, NoSuchRealmException
ClassNotFoundException
- If the class cannot be found.NoSuchRealmException
- If the specified main entry realm does not exist.public ClassRealm getMainRealm() throws NoSuchRealmException
NoSuchRealmException
- If the specified main entry realm does not exist.protected Method getEnhancedMainMethod() throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException
ClassNotFoundException
- If the main entry class cannot be found.NoSuchMethodException
- If the main entry method cannot be found.NoSuchRealmException
- If the main entry realm cannot be found.protected Method getMainMethod() throws ClassNotFoundException, NoSuchMethodException, NoSuchRealmException
ClassNotFoundException
- If the main entry class cannot be found.NoSuchMethodException
- If the main entry method cannot be found.NoSuchRealmException
- If the main entry realm cannot be found.public void launch(String[] args) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchRealmException
args
- The application args.ClassNotFoundException
- If the main entry class cannot be found.IllegalAccessException
- If the method cannot be accessed.InvocationTargetException
- If the target of the invokation is invalid.NoSuchMethodException
- If the main entry method cannot be found.NoSuchRealmException
- If the main entry realm cannot be found.protected void launchEnhanced(String[] args) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchRealmException
public static void main(String[] args, ClassWorld world)
args
- The application args.ClassNotFoundException
- If the main entry class cannot be found.IllegalAccessException
- If the method cannot be accessed.InvocationTargetException
- If the target of the invokation is
invalid.NoSuchMethodException
- If the main entry method cannot be found.NoSuchRealmException
- If the main entry realm cannot be found.protected void launchStandard(String[] args) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, NoSuchMethodException, NoSuchRealmException
public static void main(String[] args)
args
- The application args.ClassNotFoundException
- If the main entry class cannot be found.IllegalAccessException
- If the method cannot be accessed.InvocationTargetException
- If the target of the invokation is
invalid.NoSuchMethodException
- If the main entry method cannot be found.NoSuchRealmException
- If the main entry realm cannot be found.public static void main(String[] args)
args
- The application command-line arguments.Copyright © 2002–2014 Codehaus. All rights reserved.