org.codehaus.classworlds

Class EmbeddedLauncher


public class EmbeddedLauncher
extends Launcher

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.

Version:
$Id: EmbeddedLauncher.java 78 2004-07-01 13:59:13Z jvanzyl $
Author:
bob mcwhirter

Field Summary

Fields inherited from class org.codehaus.classworlds.Launcher

CLASSWORLDS_CONF, UBERJAR_CONF_DIR, mainClassName, mainRealmName, systemClassLoader, world

Constructor Summary

EmbeddedLauncher()

Method Summary

protected Method
getEnhancedMainMethod()
Retrieve the enhanced main entry method.
Class
getMainClass()
Retrieve the main entry class.
String
getMainClassName()
Retrieve the main entry class name.
ClassRealm
getMainRealm()
Retrieve the main entry realm.
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(String mainClassName, String mainRealmName)
Set the application's main entrypoint.

Methods inherited from class org.codehaus.classworlds.Launcher

configure, getEnhancedMainMethod, getExitCode, getMainClass, getMainClassName, getMainMethod, getMainRealm, getMainRealmName, getSystemClassLoader, getWorld, launch, launchEnhanced, launchStandard, main, mainWithExitCode, setAppMain, setSystemClassLoader, setWorld

Constructor Details

EmbeddedLauncher

public EmbeddedLauncher()

Method Details

getEnhancedMainMethod

protected Method getEnhancedMainMethod()
            throws ClassNotFoundException,
                   NoSuchMethodException,
                   NoSuchRealmException
Retrieve the enhanced main entry method.
Overrides:
getEnhancedMainMethod in interface Launcher
Returns:
The enhanced main entry method.
Throws:
NoSuchRealmException - If the main entry realm cannot be found.

getMainClass

public Class getMainClass()
            throws ClassNotFoundException,
                   NoSuchRealmException
Retrieve the main entry class.
Overrides:
getMainClass in interface Launcher
Returns:
The main entry class.
Throws:
NoSuchRealmException - If the specified main entry realm does not exist.

getMainClassName

public String getMainClassName()
Retrieve the main entry class name.
Overrides:
getMainClassName in interface Launcher
Returns:
The main entry class name.

getMainRealm

public ClassRealm getMainRealm()
            throws NoSuchRealmException
Retrieve the main entry realm.
Overrides:
getMainRealm in interface Launcher
Returns:
The main entry realm.
Throws:
NoSuchRealmException - If the specified main entry realm does not exist.

getMainRealmName

public String getMainRealmName()
Retrieve the main entry realm name.
Overrides:
getMainRealmName in interface Launcher
Returns:
The main entry realm name.

launch

public void launch()
            throws Exception

launchX

protected void launchX()
            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)
  
Throws:
NoSuchRealmException - If the main entry realm cannot be found.

setAppMain

public void setAppMain(String mainClassName,
                       String mainRealmName)
Set the application's main entrypoint.
Overrides:
setAppMain in interface Launcher
Parameters:
mainClassName - The main class name.
mainRealmName - The realm to load the class from.