|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.plexus.classworlds.launcher.Launcher
public class Launcher
Command-line invokable application launcher.
This launcher class assists in the creation of classloaders andClassRealm
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
.
Field Summary | |
---|---|
protected static java.lang.String |
CLASSWORLDS_CONF
|
protected java.lang.String |
mainClassName
|
protected java.lang.String |
mainRealmName
|
protected java.lang.ClassLoader |
systemClassLoader
|
protected static java.lang.String |
UBERJAR_CONF_DIR
|
protected ClassWorld |
world
|
Constructor Summary | |
---|---|
Launcher()
|
Method Summary | |
---|---|
void |
configure(java.io.InputStream is)
Configure from a file. |
protected java.lang.reflect.Method |
getEnhancedMainMethod()
Retrieve the enhanced main entry method. |
int |
getExitCode()
|
java.lang.Class |
getMainClass()
Retrieve the main entry class. |
java.lang.String |
getMainClassName()
|
protected java.lang.reflect.Method |
getMainMethod()
Retrieve the main entry method. |
ClassRealm |
getMainRealm()
Retrieve the main entry realm. |
java.lang.String |
getMainRealmName()
|
java.lang.ClassLoader |
getSystemClassLoader()
|
ClassWorld |
getWorld()
|
void |
launch(java.lang.String[] args)
Launch the application. |
protected void |
launchEnhanced(java.lang.String[] args)
Attempt to launch the application through the enhanced main method. |
protected void |
launchStandard(java.lang.String[] args)
Attempt to launch the application through the standard main method. |
static void |
main(java.lang.String[] args)
Launch the launcher from the command line. |
static int |
mainWithExitCode(java.lang.String[] args)
Launch the launcher. |
void |
setAppMain(java.lang.String mainClassName,
java.lang.String mainRealmName)
|
void |
setSystemClassLoader(java.lang.ClassLoader loader)
|
void |
setWorld(ClassWorld world)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.lang.String CLASSWORLDS_CONF
protected static final java.lang.String UBERJAR_CONF_DIR
protected java.lang.ClassLoader systemClassLoader
protected java.lang.String mainClassName
protected java.lang.String mainRealmName
protected ClassWorld world
Constructor Detail |
---|
public Launcher()
Method Detail |
---|
public void setSystemClassLoader(java.lang.ClassLoader loader)
public java.lang.ClassLoader getSystemClassLoader()
public int getExitCode()
public void setAppMain(java.lang.String mainClassName, java.lang.String mainRealmName)
public java.lang.String getMainRealmName()
public java.lang.String getMainClassName()
public void setWorld(ClassWorld world)
public ClassWorld getWorld()
public void configure(java.io.InputStream is) throws java.io.IOException, ConfigurationException, DuplicateRealmException, NoSuchRealmException
is
- The config input stream.
java.io.IOException
- If an error occurs reading the config file.
java.net.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 java.lang.Class getMainClass() throws java.lang.ClassNotFoundException, NoSuchRealmException
java.lang.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 java.lang.reflect.Method getEnhancedMainMethod() throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, NoSuchRealmException
java.lang.ClassNotFoundException
- If the main entry class cannot be found.
java.lang.NoSuchMethodException
- If the main entry method cannot be found.
NoSuchRealmException
- If the main entry realm cannot be found.protected java.lang.reflect.Method getMainMethod() throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, NoSuchRealmException
java.lang.ClassNotFoundException
- If the main entry class cannot be found.
java.lang.NoSuchMethodException
- If the main entry method cannot be found.
NoSuchRealmException
- If the main entry realm cannot be found.public void launch(java.lang.String[] args) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException, NoSuchRealmException
args
- The application args.
java.lang.ClassNotFoundException
- If the main entry class cannot be found.
java.lang.IllegalAccessException
- If the method cannot be accessed.
java.lang.reflect.InvocationTargetException
- If the target of the invokation is invalid.
java.lang.NoSuchMethodException
- If the main entry method cannot be found.
NoSuchRealmException
- If the main entry realm cannot be found.protected void launchEnhanced(java.lang.String[] args) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException, NoSuchRealmException
public static void main(String[] args, ClassWorld world)
args
- The application args.
java.lang.ClassNotFoundException
- If the main entry class cannot be found.
java.lang.IllegalAccessException
- If the method cannot be accessed.
java.lang.reflect.InvocationTargetException
- If the target of the invokation is
invalid.
java.lang.NoSuchMethodException
- If the main entry method cannot be found.
NoSuchRealmException
- If the main entry realm cannot be found.protected void launchStandard(java.lang.String[] args) throws java.lang.ClassNotFoundException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException, NoSuchRealmException
public static void main(String[] args)
args
- The application args.
java.lang.ClassNotFoundException
- If the main entry class cannot be found.
java.lang.IllegalAccessException
- If the method cannot be accessed.
java.lang.reflect.InvocationTargetException
- If the target of the invokation is
invalid.
java.lang.NoSuchMethodException
- If the main entry method cannot be found.
NoSuchRealmException
- If the main entry realm cannot be found.public static void main(java.lang.String[] args)
args
- The application command-line arguments.public static int mainWithExitCode(java.lang.String[] args) throws java.lang.Exception
args
- The application command-line arguments.
java.lang.Exception
- If an error occurs.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |