net.sf.sfac.launcher
Class ApplicationLauncher

java.lang.Object
  extended by net.sf.sfac.launcher.ApplicationLauncher

public class ApplicationLauncher
extends Object

Class able to dynamically setup the java classpath and launch another main class using this new classpath.
It uses a URLClassLoader to dynamically load all the jars in a given directory (like "./lib").

See displayUsage() method for command line explanations.

This class is alone in one Maven project to be able to produce a jar containing only this class. It's because, it's better that all the jars of the application are in a single ClassLoader (the URLClassLoader setup by this class). So, to avoid class loading problems, it's better that the intermediate ClassLoader (the usual application ClassLoader) contains as less class as possible.

Author:
Olivier Berlanger

Field Summary
static String BASE_DIR_KEY
           
static String EXTRA_PARAMS_KEY
           
static String LAUNCHER_PROPERTIES_KEY
           
static String LIB_PATH_KEY
           
static String MAIN_CLASS_KEY
           
static String RECURSIVE_LIB_SEARCH_KEY
           
static String SHOW_HELP_KEY
           
static String SPLASH_IMG_KEY
           
static String VERBOSE_KEY
           
 
Constructor Summary
ApplicationLauncher(Properties cmdLineProperties)
          Instantiate a launcher using the given 'library' directories.
 
Method Summary
 File getBaseDir()
           
static File getBaseDirectory()
           
 void launchApplication()
          Start given the application using the newly instantiated URLClassloader.
static void main(String[] args)
          Parse the argument string to instantiate the ApplicationLauncher and call startApplication on it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAUNCHER_PROPERTIES_KEY

public static final String LAUNCHER_PROPERTIES_KEY
See Also:
Constant Field Values

BASE_DIR_KEY

public static final String BASE_DIR_KEY
See Also:
Constant Field Values

MAIN_CLASS_KEY

public static final String MAIN_CLASS_KEY
See Also:
Constant Field Values

EXTRA_PARAMS_KEY

public static final String EXTRA_PARAMS_KEY
See Also:
Constant Field Values

LIB_PATH_KEY

public static final String LIB_PATH_KEY
See Also:
Constant Field Values

SPLASH_IMG_KEY

public static final String SPLASH_IMG_KEY
See Also:
Constant Field Values

VERBOSE_KEY

public static final String VERBOSE_KEY
See Also:
Constant Field Values

RECURSIVE_LIB_SEARCH_KEY

public static final String RECURSIVE_LIB_SEARCH_KEY
See Also:
Constant Field Values

SHOW_HELP_KEY

public static final String SHOW_HELP_KEY
See Also:
Constant Field Values
Constructor Detail

ApplicationLauncher

public ApplicationLauncher(Properties cmdLineProperties)
Instantiate a launcher using the given 'library' directories.

Parameters:
libDirectories - List of directories containing the jar files to add to the classpath
verbose - When true, display verbose messages to System.out
Method Detail

getBaseDir

public File getBaseDir()

launchApplication

public void launchApplication()
                       throws Exception
Start given the application using the newly instantiated URLClassloader.
All parameters are defined in the launcherProperties map.

Throws:
Exception

main

public static void main(String[] args)
Parse the argument string to instantiate the ApplicationLauncher and call startApplication on it.
See displayUsage() method for command line explanaitions.


getBaseDirectory

public static File getBaseDirectory()


Copyright © 2011. All Rights Reserved.