THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
I will be creating a prototype implementation in my whiteboard
6 Alternative Approach
The launchpad/base module creates two artifacts: The primary artifact is included with the final application. The secondary artifact is the actual launcher JAR file.
6.1 Primary Artifact
The primary artifact contains three elements:
Notifier
interface with two methodsstopped
– called when the framework has been stopped – andupdated
– called when the framework has been updated and needs to be restarted. This interface is to be implemented by the main class or servlet.Loader
creates theURLClassLoader
with the launcher JAR and instantiates the launcher class. This class is implemented as a utility class with a two methodsloadLauncher
andcleanupVM
:
Code Block |
---|
/**
* Creates an URLClassLoader from a _launcher JAR_ file in the given
* slingHome directory and loads and returns the launcher class
* identified by the launcherClassName.
* @param launcherClassName The fully qualified name of a class
* implementing the Launcher interface. This class must have
* a public constructor taking no arguments.
* @param slingHome The value to be used as ${slingHome}. This may
* be null in which case the sling folder in the current working
* directory is assumed. If this name is empty, the current working
* directory is assumed to be used as ${slingHome}.
* @return the Launcher instance loaded from the newly created classloader
* @throws NullPointerException if launcherClassName is null
* @throws IllegalArgumentException if the launcherClassName cannot be
* instantiated. The cause of the failure is contained as the cause
* of the exception.
*/
public static Launcher loadLauncher(String launcherClassName, String slingHome);
/**
* Tries to remove as many traces of class loaded by the framework from
* the Java VM as possible. Most notably the following traces are removed:
* <ul>
* <li>JavaBeans property caches
* <li>Java Logging caches
* </ul>
* <p>
* This method must be called when the notifier is called.
*/
public static void cleanupVM();
|
Launcher
interface which is implemented by classes in the secondary artifact. This interface has a method to support the standaline Java Application case (setCommandLine
). To support the Web Application, the launcher class is expected to implement thejavax.servlet.Servlet
interface. TheLauncher
interface is defined as follows:
Code Block |
---|
// sets command line arguments, mainly used by the main class
public void setCommandLine(String[] args);
// starts the framework
public void start();
// stops the framework
// this method only returns when the framework has actually been stopped.
// this method may be used by the main class or servlet to initiate a
// shutdown of the framework
public void stop();
|