org.schmant.tpm
Class TaskPackage

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

public class TaskPackage
extends Object

This object contains information on a task package. It is managed by the TaskPackageManager.

Through this object, task packages can access their files.

Since:
0.8
Author:
Karl Gustafsson
See Also:
TaskPackageManager

Method Summary
 void enable()
          Enable this task package.
 TaskPackageClassLoader getClassLoader()
          Get the class loader used for loading classes in this task package.
 String getClassLoaderName()
          Get the name of the class loader that this task package will use.
 Set<String> getJavaPackageNames()
          Get the names of the Java packages that should be automatically imported when this task package is enabled.
 String getName()
          Get the task package's name.
 Directory getRootDirectory()
          Get the task package's root directory.
 boolean isEnabled()
          Is this task package enabled?
 EFile makeFileBacked(EFile f)
          Make the file support the FCFileBacked capability.
 EFile makeRandomlyAccessible(EFile f)
          Make the file support the FCRandomAccess capability.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getName

public String getName()
Get the task package's name.

Returns:
A name, such as org.schmant.task.base.

getRootDirectory

public Directory getRootDirectory()
Get the task package's root directory.

Returns:
The task package's root directory.

getJavaPackageNames

public Set<String> getJavaPackageNames()
Get the names of the Java packages that should be automatically imported when this task package is enabled.

Returns:
An unmodifiable set of Java package names.

getClassLoaderName

public String getClassLoaderName()
Get the name of the class loader that this task package will use. By default, this name is the same as the task package name, but if a task package wants to collaborate closely with another task package, it may use the same class loader name as that package to load its classes in the same class loader. By doing that, the classes of this task package are visible to that other task package's classes and vice versa, even if isolated class loaders are used.

Returns:
The name of a class loader.

getClassLoader

public TaskPackageClassLoader getClassLoader()
Get the class loader used for loading classes in this task package. If the class loading strategy is shared, this class loader is shared among all task packages. If it is isolated, this class loader is unique for this task package's class loader name.

Returns:
The task package's class loader.
See Also:
getClassLoaderName()

isEnabled

public boolean isEnabled()
Is this task package enabled?

Returns:
true if this task package is enabled.

enable

public void enable()
Enable this task package.

Enabling a task package makes all its classes available to the named class loader used by it. By default the class loader name is the same as the task package name, but this may be overridden by the task package configuration if the task package wants to collaborate with classes from another task package. See getClassLoaderName().


makeRandomlyAccessible

public EFile makeRandomlyAccessible(EFile f)
Make the file support the FCRandomAccess capability.

If the file does not already do so (if the file is stored in a Zip file, for instance), it is copied to an in-memory file system that is specific for this task package.

Parameters:
f - The file to make randomly accessible. The file must be somewhere in this task package, i.e. somewhere under the directory returned by getRootDirectory().
Returns:
A randomly accessible version of the supplied file.
See Also:
makeFileBacked(EFile)

makeFileBacked

public EFile makeFileBacked(EFile f)
Make the file support the FCFileBacked capability. In other words: make sure that the file is backed by a java.io.File object.

If the file does not already is so (if the file is stored in a Zip file, for instance), it is copied to a temporary directory that is specific for this task package. The temporary file is deleted when the build script terminates.

Parameters:
f - The file to make File-backed. The file must be somewhere in this task package, i.e. somewhere under the directory returned by getRootDirectory().
Returns:
A file-backed version of the supplied file. The File object backing the file entity can be retrieved using the ECFileResolvableUtil.getFileObject(org.entityfs.EntityView) method.
See Also:
makeRandomlyAccessible(EFile)