org.freecompany.brimstone.main
Class Main

java.lang.Object
  extended by org.freecompany.brimstone.main.Main
All Implemented Interfaces:
java.lang.Thread.UncaughtExceptionHandler, Runner

public class Main
extends java.lang.Object
implements Runner, java.lang.Thread.UncaughtExceptionHandler


Field Summary
protected  java.lang.String[] arguments
           
 java.lang.String clazz
           
 java.lang.String method
           
protected  java.lang.ClassLoader parent
           
 java.lang.String path
           
protected  java.util.concurrent.atomic.AtomicBoolean restart
           
 
Constructor Summary
Main()
           
 
Method Summary
protected  void configure(java.lang.String[] arguments)
           
static Runner getRunner()
           
static void main(java.lang.String[] arguments)
           
 void restart()
          Indicates the main that after the application thread terminates it should be restarted.
 void setArguments(java.lang.String[] arguments)
          Provides arguments to be passed to the specified static run method.
 void setClass(java.lang.String clazz)
          Sets the class name that the main will load as the entry point to the application.
 void setMethod(java.lang.String method)
          Sets the method name used to start the application.
 void setParent(java.lang.ClassLoader parent)
          Sets the ClassLoader this main should use as the parent of the ClassLoader that will be built from the provided path.
 void setPath(java.lang.String path)
          Comma-separated list of URL strings that the main will use to look up the Class and Method instances used to load and run the wrapped application.
 void start()
          Starts the application as described by the three attributes above.
 void uncaughtException(java.lang.Thread t, java.lang.Throwable e)
          The default exception handler will simply log a SEVERE level message with the exception object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

path

public java.lang.String path

clazz

public java.lang.String clazz

method

public java.lang.String method

restart

protected final java.util.concurrent.atomic.AtomicBoolean restart

parent

protected java.lang.ClassLoader parent

arguments

protected java.lang.String[] arguments
Constructor Detail

Main

public Main()
Method Detail

getRunner

public static Runner getRunner()

main

public static void main(java.lang.String[] arguments)
                 throws java.lang.Exception
Throws:
java.lang.Exception

configure

protected void configure(java.lang.String[] arguments)
                  throws java.lang.ClassNotFoundException
Throws:
java.lang.ClassNotFoundException

setPath

public void setPath(java.lang.String path)
Description copied from interface: Runner
Comma-separated list of URL strings that the main will use to look up the Class and Method instances used to load and run the wrapped application. This set of locations will also serve as the runtime classpath for the loaded application.

Specified by:
setPath in interface Runner
Parameters:
path - a list of urls to load from.

setClass

public void setClass(java.lang.String clazz)
Description copied from interface: Runner
Sets the class name that the main will load as the entry point to the application.

Specified by:
setClass in interface Runner
Parameters:
clazz - class name of the main application.

setMethod

public void setMethod(java.lang.String method)
Description copied from interface: Runner
Sets the method name used to start the application. This method must be a static method on the Class loaded by name from the clazz attribute.

Specified by:
setMethod in interface Runner
Parameters:
method - name to invoke when starting the application.

setParent

public void setParent(java.lang.ClassLoader parent)
Description copied from interface: Runner
Sets the ClassLoader this main should use as the parent of the ClassLoader that will be built from the provided path. This defaults to the classloader of the main implementation itself and if it is overridden applications executed through this main may not to resolve and use this management interface.

Specified by:
setParent in interface Runner
Parameters:
parent - the ClassLoader to be used as the parent of the application ClassLoader.

setArguments

public void setArguments(java.lang.String[] arguments)
Description copied from interface: Runner
Provides arguments to be passed to the specified static run method. The default is to not provide any arguments when the main is invoked programmatically. If the main is being invoked through its main method then the default is to provide all the arguments supplied to the main that do not match known optins in the main itself.

Specified by:
setArguments in interface Runner
Parameters:
arguments - arguments for the main method.

start

public void start()
           throws java.lang.ClassNotFoundException,
                  java.lang.NoSuchMethodException,
                  java.lang.IllegalAccessException,
                  java.net.URISyntaxException,
                  java.net.MalformedURLException,
                  java.io.IOException
Description copied from interface: Runner
Starts the application as described by the three attributes above.

Specified by:
start in interface Runner
Throws:
java.lang.ClassNotFoundException - if the specified class can not be found.
java.lang.NoSuchMethodException - the specified method is not a static method on the given class.
java.lang.IllegalAccessException - the provided class or method cannot be accessed from this application.
java.net.URISyntaxException - if a
java.net.MalformedURLException
java.io.IOException

restart

public void restart()
Description copied from interface: Runner
Indicates the main that after the application thread terminates it should be restarted. Any changes made to the path, class or method will be used when restarting the application. This method is useful for updating an application either by overwriting the JAR file or by setting up a new path before exiting.

Specified by:
restart in interface Runner

uncaughtException

public void uncaughtException(java.lang.Thread t,
                              java.lang.Throwable e)
The default exception handler will simply log a SEVERE level message with the exception object.

Specified by:
uncaughtException in interface java.lang.Thread.UncaughtExceptionHandler
Parameters:
t - the thread which caused the exception.
e - the exception.