Package org.codehaus.classworlds
Class EmbeddedLauncher
- java.lang.Object
-
- org.codehaus.classworlds.Launcher
-
- org.codehaus.classworlds.EmbeddedLauncher
-
public class EmbeddedLauncher extends 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'smain
method from the correct class loaded through the correct classloader. The path to the configuration file is specified using theclassworlds.conf
system property, typically specified using the-D
switch tojava
.- Version:
- $Id: EmbeddedLauncher.java 78 2004-07-01 13:59:13Z jvanzyl $
- Author:
- bob mcwhirter
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
LAUNCH_METHOD
-
Fields inherited from class org.codehaus.classworlds.Launcher
CLASSWORLDS_CONF, mainClassName, mainRealmName, systemClassLoader, UBERJAR_CONF_DIR, world
-
-
Constructor Summary
Constructors Constructor Description EmbeddedLauncher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.reflect.Method
getEnhancedMainMethod()
Retrieve the enhanced main entry method.java.lang.Class
getMainClass()
Retrieve the main entry class.java.lang.String
getMainClassName()
Retrieve the main entry class name.ClassRealm
getMainRealm()
Retrieve the main entry realm.java.lang.String
getMainRealmName()
Retrieve the main entry realm name.void
launch()
protected void
launchX()
Attempt to launch the application through the enhanced main method.void
setAppMain(java.lang.String mainClassName, java.lang.String mainRealmName)
Set the application's main entrypoint.-
Methods inherited from class org.codehaus.classworlds.Launcher
configure, getExitCode, getMainMethod, getSystemClassLoader, getWorld, launch, launchEnhanced, launchStandard, main, mainWithExitCode, setSystemClassLoader, setWorld
-
-
-
-
Method Detail
-
setAppMain
public void setAppMain(java.lang.String mainClassName, java.lang.String mainRealmName)
Set the application's main entrypoint.- Overrides:
setAppMain
in classLauncher
- Parameters:
mainClassName
- The main class name.mainRealmName
- The realm to load the class from.
-
getMainRealmName
public java.lang.String getMainRealmName()
Retrieve the main entry realm name.- Overrides:
getMainRealmName
in classLauncher
- Returns:
- The main entry realm name.
-
getMainClassName
public java.lang.String getMainClassName()
Retrieve the main entry class name.- Overrides:
getMainClassName
in classLauncher
- Returns:
- The main entry class name.
-
getMainClass
public java.lang.Class getMainClass() throws java.lang.ClassNotFoundException, NoSuchRealmException
Retrieve the main entry class.- Overrides:
getMainClass
in classLauncher
- Returns:
- The main entry class.
- Throws:
java.lang.ClassNotFoundException
- If the class cannot be found.NoSuchRealmException
- If the specified main entry realm does not exist.
-
getMainRealm
public ClassRealm getMainRealm() throws NoSuchRealmException
Retrieve the main entry realm.- Overrides:
getMainRealm
in classLauncher
- Returns:
- The main entry realm.
- Throws:
NoSuchRealmException
- If the specified main entry realm does not exist.
-
getEnhancedMainMethod
protected java.lang.reflect.Method getEnhancedMainMethod() throws java.lang.ClassNotFoundException, java.lang.NoSuchMethodException, NoSuchRealmException
Retrieve the enhanced main entry method.- Overrides:
getEnhancedMainMethod
in classLauncher
- Returns:
- The enhanced main entry method.
- Throws:
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.
-
launchX
protected void launchX() 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)
- Throws:
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.
-
launch
public void launch() throws java.lang.Exception
- Throws:
java.lang.Exception
-
-