org.freecompany.brimstone.main
Interface Runner

All Known Implementing Classes:
Main

public interface Runner

Exposes a basic control interface for applications running under the Brimstone main. The methods exposed allow for basic lifecycle management, allowing for starting, stopping, and restaring the application.


Method Summary
 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.
 

Method Detail

setParent

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. 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.

Parameters:
parent - the ClassLoader to be used as the parent of the application ClassLoader.

setPath

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. This set of locations will also serve as the runtime classpath for the loaded application.

Parameters:
path - a list of urls to load from.

setClass

void setClass(java.lang.String clazz)
Sets the class name that the main will load as the entry point to the application.

Parameters:
clazz - class name of the main application.

setMethod

void setMethod(java.lang.String method)
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.

Parameters:
method - name to invoke when starting the application.

setArguments

void setArguments(java.lang.String[] arguments)
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.

Parameters:
arguments - arguments for the main method.

start

void start()
           throws java.lang.ClassNotFoundException,
                  java.lang.NoSuchMethodException,
                  java.lang.IllegalAccessException,
                  java.net.URISyntaxException,
                  java.net.MalformedURLException,
                  java.io.IOException
Starts the application as described by the three attributes above.

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

void restart()
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.