|
JavaGantt 2011.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecteu.beesoft.gaia.launcher.Launcher
public class Launcher
The main class of the launch system. It supports processing of the
instruction file, building a splash screen, building the class paths and
invoking main
method on another class.
You can use this class in JAR file as is, or you can subclass this class, build your own JAR file (copy to it all files from this JAR) and use it to launch your application.
Launcher processes launch
file. It is a file with the
instructions. Enabled instructions are:
SplashScreen
. An
image name is an argument of the call.main()
method on instance of the class,
which name and arguments for invocation are in given argument
You can extend this instruction set when you override method
processInstruction(String)
and process the new instructions in it.
Here is an example of the standard launch file:
path c:/myapp/lib/first.jar path c:/myapp/lib/second.jar path c:/myapp/classes run mypackage.MyClass firstArgument "second argument"
It creates a classpath from two JAR files and one directory and then invokes method main() on MyClass with two arguments.
Constructor Summary | |
---|---|
protected |
Launcher()
Creates a new instance of Launcher. |
Method Summary | |
---|---|
protected void |
addClassPath(java.lang.String classPath)
Adds given argument to the classpath list. |
protected void |
addSystemProperty(java.lang.String configurationArgument)
Parses given configurationArgument to property name and
property value and adds it to system properties. |
protected java.lang.ClassLoader |
buildClassLoader()
Builds a class loader initialized by the class paths set by addClassPath(String) and scanClassPath(String) . |
protected void |
buildProgressMediator(java.lang.String configurationArgument)
Builds a progress mediator as an instance of given configurationArgument . |
protected void |
buildSplashScreen(java.lang.String configurationArgument)
Builds a splash screen as instance of SplashScreen with image
which resource name is given configurationArgument . |
protected void |
clearClassPath()
Clears a list of class pathes prepared to invoke some class. |
protected java.util.List<java.lang.String> |
getClassPath()
Returns a list of class pathes prepared to invoke some class. |
protected java.io.File |
getFile(java.lang.String name)
Returns a file with given name from a directory where JAR file of this Launcher is located. |
static Launcher |
getInstance()
Returns a current instance of Launcher. |
java.io.File |
getLauncherJarFile()
Returns a JAR file where this Launcher resides. |
java.util.jar.Manifest |
getManifest()
Returns a manifest from JAR file where this Launcher resides. |
ProgressMediator |
getProgressMediator()
Returns progress mediator instance. |
protected void |
invokeMain(java.lang.String configurationArgument)
Invokes a static main() method on the class and with
arguments that are in the given configurationArgument . |
protected void |
invokeMain(java.lang.String className,
java.lang.String[] arguments)
Invokes a static main() method on the class with given
className() and with given arguments . |
static void |
main(java.lang.String[] arg)
Creates and starts (not subclassed) instance of Launcher . |
protected void |
processInstruction(java.lang.String instructionLine)
Processes one-line instruction. |
protected void |
processInstruction(java.lang.String instruction,
java.lang.String argument)
Processes given instruction. |
protected void |
processInstructions(java.io.File file)
Processes instructions from a given file. |
protected void |
processInstructions(java.lang.String fileName)
Processes instructions from file with given name. |
protected void |
scanClassPath(java.lang.String classPath)
Scans directory with given name (= argument classPath) and all its subdirectories. |
protected void |
setProgressMediator(ProgressMediator progressMediator)
Sets a new progress mediator. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected Launcher()
getInstance()
).
Method Detail |
---|
public static Launcher getInstance()
public ProgressMediator getProgressMediator()
protected void setProgressMediator(ProgressMediator progressMediator)
progressMediator
- - the progress mediator to setpublic java.util.jar.Manifest getManifest()
public java.io.File getLauncherJarFile()
protected java.io.File getFile(java.lang.String name)
name
- - a name of the requested file
java.lang.RuntimeException
- if cannot find fileprotected void processInstructions(java.lang.String fileName)
fileName
- - a name of the requested file with instructionsprotected void processInstructions(java.io.File file)
file
- - file with instructionsprotected void processInstruction(java.lang.String instructionLine)
processInstruction(String, String)
to process it.
instructionLine
- - instruction to processprotected void processInstruction(java.lang.String instruction, java.lang.String argument)
SplashScreen
.
An image name is an argument of the call.main()
method on instance of the
class, which name and arguments for invocation are in given argument
instruction
- - instruction to processargument
- - argument for instructionprotected void addClassPath(java.lang.String classPath)
classPath
- - a class path to addprotected void scanClassPath(java.lang.String classPath)
classPath
- - a name of the directory to scanprotected java.util.List<java.lang.String> getClassPath()
protected void clearClassPath()
protected void addSystemProperty(java.lang.String configurationArgument)
configurationArgument
to property name and
property value and adds it to system properties. If
configurationArgument
is null, is empty, or does not contain
separator character like '=', ':' or ' ' (space), it does nothing.
configurationArgument
- - property name and property value separated by separator
character like '=', ':' or ' ' (space)protected void buildSplashScreen(java.lang.String configurationArgument)
SplashScreen
with image
which resource name is given configurationArgument
.
configurationArgument
- - file or class path name of the image for splash screenprotected void buildProgressMediator(java.lang.String configurationArgument)
configurationArgument
.
configurationArgument
- - class name of the progress mediatorprotected java.lang.ClassLoader buildClassLoader()
addClassPath(String)
and scanClassPath(String)
.
protected void invokeMain(java.lang.String configurationArgument)
main()
method on the class and with
arguments that are in the given configurationArgument
. After
parsing of it this method invokes invokeMain(String, String[])
.
configurationArgument
- - contains a class name and arguments for main
method. Single items are separated by space. A multi-word
argument should be in quotes.protected void invokeMain(java.lang.String className, java.lang.String[] arguments)
main()
method on the class with given
className()
and with given arguments
. A class
is loaded with new class loader returned by buildClassLoader()
method.
className
- - name of the class on which shold be method
main()
invokedarguments
- - arguments for main()
methodpublic static void main(java.lang.String[] arg)
Launcher
. If
there is no value in arg[0]
, it searches for the file with
the same name as has a JAR file with this Launcher class and with
extension '.launch
'. Otherwise it uses arg[0]
as name of that file. This file is in next processed by
processInstructions(String)
method.
arg
- - if is not null, first argument must contain name of the
launch file
|
JavaGantt 2011.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |