org.schmant.tpm
Class TaskPackageManager

java.lang.Object
  extended by org.schmant.tpm.TaskPackageManager

public final class TaskPackageManager
extends Object

The TaskPackageManager handles the enabled task packages.

When a task package is enabled, the TaskPackageManager searches through all directories in the task package path (the -t command line argument) for directories with the same name as the task package to enable (task package directories). The task package path directories are searched in the order that they are given in the task package path.

For every task package directory found, when it is found, the entries in the task package directory's lib directory are added to the classpath.

Mostly, a task package does only have one task package directory. A reason for having more than one would be if the task package is patched. In that case the patch task package path directory is added before the regular task package path directory to the task package path, making patch jars take precedence over regular jars.

The Launcher class creates a new TaskPackageManager object and stores it as an inheritable thread local on this class (s_taskPackageManager). After it has run, Launcher restores the previous instance (which often will be null).

Build scripts should never have to bother with the task package manager.

Since:
0.5
Author:
Karl Gustafsson

Field Summary
static String TASK_PACKAGE_INFO_FILE_NAME
           
 
Constructor Summary
TaskPackageManager()
          Create an empty task package manager.
TaskPackageManager(Report r, String tpp)
           
 
Method Summary
 void close()
          Shut down the task package manager.
 TaskPackage createTaskPackage(Directory d)
          Create a new task package from the contents in the directory and register it with this task package manager.
protected  void finalize()
           
static TaskPackageManager get()
          Get the current task package manager.
 TaskPackage getTaskPackage(String name)
          Get the named task package.
static TaskPackageManager init(TaskPackageManager tpm)
          This is called by Launcher to initialize this class.
static void registerTaskPackageEnableCallback(TaskPackageEnableCallback c)
          A ScriptExecutor can use this method to register a callback object that will be notified before and after a TaskPackage is enabled.
static void tearDown(TaskPackageManager prevManager)
          This is called by Launcher to tear down this class.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TASK_PACKAGE_INFO_FILE_NAME

public static final String TASK_PACKAGE_INFO_FILE_NAME
See Also:
Constant Field Values
Constructor Detail

TaskPackageManager

public TaskPackageManager(Report r,
                          String tpp)
Parameters:
tpp - The task package path, separated by File.separatorChar

TaskPackageManager

public TaskPackageManager()
Create an empty task package manager. This should only be used by unit tests.

Method Detail

init

public static TaskPackageManager init(TaskPackageManager tpm)
This is called by Launcher to initialize this class.

Parameters:
tpm - The new task package manager.
Returns:
A previous task package manager, if any. This object is used later on when Launcher calls tearDown(TaskPackageManager).
See Also:
tearDown(TaskPackageManager)

tearDown

public static void tearDown(TaskPackageManager prevManager)
This is called by Launcher to tear down this class.

Parameters:
prevManager - The object returned by init(TaskPackageManager).
See Also:
init(TaskPackageManager)

get

public static TaskPackageManager get()
Get the current task package manager.

Returns:
The current task package manager.

registerTaskPackageEnableCallback

public static void registerTaskPackageEnableCallback(TaskPackageEnableCallback c)
A ScriptExecutor can use this method to register a callback object that will be notified before and after a TaskPackage is enabled.

Parameters:
c - The callback object.

createTaskPackage

public TaskPackage createTaskPackage(Directory d)
                              throws TaskPackageNotFoundException
Create a new task package from the contents in the directory and register it with this task package manager.

There is normally no reason for anyone other than the task package manager itself to call this method.

Parameters:
d - The root directory of the task package.
Returns:
A new TaskPackage object or null if one could not be created.
Throws:
TaskPackageNotFoundException - If the supplied directory is not the root directory of a task package.

getTaskPackage

public TaskPackage getTaskPackage(String name)
                           throws TaskPackageNotFoundException
Get the named task package.

Parameters:
name - The name of the task package. The name is not case-sensitive.
Returns:
The task package.
Throws:
TaskPackageNotFoundException - If there is no task package with the given name.

close

public void close()
Shut down the task package manager. This is called by the Schmant Launcher class.


finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable