org.apache.sling.launchpad.base.shared
Class Loader

java.lang.Object
  extended by org.apache.sling.launchpad.base.shared.Loader

public class Loader
extends java.lang.Object

The Loader class provides utility methods for the actual launchers to help launching the framework.


Constructor Summary
Loader()
           
 
Method Summary
static void cleanupVM()
          Tries to remove as many traces of class loaded by the framework from the Java VM as possible.
static boolean installLauncherJar(java.net.URL launcherJar, java.lang.String slingHome)
          Copies the contents of the launcher JAR as indicated by the URL to the sling home directory and sets the last modification time stamp fo the file.
static java.lang.Object loadLauncher(java.lang.String launcherClassName, java.lang.String slingHome)
          Creates an URLClassLoader from a _launcher JAR_ file in the given slingHome directory and loads and returns the launcher class identified by the launcherClassName.
static void spool(java.io.InputStream ins, java.io.File destFile)
          Spools the contents of the input stream to the given file replacing the contents of the file with the contents of the input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Loader

public Loader()
Method Detail

loadLauncher

public static java.lang.Object loadLauncher(java.lang.String launcherClassName,
                                            java.lang.String slingHome)
Creates an URLClassLoader from a _launcher JAR_ file in the given slingHome directory and loads and returns the launcher class identified by the launcherClassName.

Parameters:
launcherClassName - The fully qualified name of a class implementing the Launcher interface. This class must have a public constructor taking no arguments.
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}.
Returns:
the Launcher instance loaded from the newly created classloader
Throws:
java.lang.NullPointerException - if launcherClassName is null
java.lang.IllegalArgumentException - if the launcherClassName cannot be instantiated. The cause of the failure is contained as the cause of the exception.

cleanupVM

public static void cleanupVM()
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:

This method must be called when the notifier is called.


installLauncherJar

public static boolean installLauncherJar(java.net.URL launcherJar,
                                         java.lang.String slingHome)
                                  throws java.io.IOException
Copies the contents of the launcher JAR as indicated by the URL to the sling home directory and sets the last modification time stamp fo the file. If the existing file is not older than the contents of the launcher JAR file, the file is not replaced.

Returns:
true if the launcher JAR file has been installed or updated. If the launcher JAR is already up to date, false is returned.
Throws:
java.io.IOException - If an error occurrs transferring the contents

spool

public static void spool(java.io.InputStream ins,
                         java.io.File destFile)
                  throws java.io.IOException
Spools the contents of the input stream to the given file replacing the contents of the file with the contents of the input stream. When this method returns, the input stream is guaranteed to be closed.

Throws:
java.io.IOException - If an error occurrs reading or writing the input stream contents.


Copyright © 2007-2009. All Rights Reserved.