net.dpml.transit.tools
Class TransitComponentHelper

java.lang.Object
  extended byorg.apache.tools.ant.ComponentHelper
      extended bynet.dpml.transit.tools.TransitComponentHelper
All Implemented Interfaces:
BuildListener, EventListener, SubBuildListener

public class TransitComponentHelper
extends ComponentHelper
implements SubBuildListener

A component helper that handles automatic loading of plugins into the ant plugin based on namespace declarations in the project file. This is similar to the 'antlib:' convention except we use the 'plugin:' convention.

Version:
1.0.1
Author:
Digital Product Meta Library

Field Summary
static String PLUGIN_ARTIFACT_HEADER
          The constant artifact plugin header.
static String TRANSIT_ANTLIB_URN
          The constant Transit ANTLIB namespace.
static String TRANSIT_GET_URN
          The constant Transit ANTLIB get task namespace.
static String TRANSIT_IMPORT_URN
          The constant Transit ANTLIB import task namespace.
static String TRANSIT_INIT_URN
          The constant Transit ANTLIB init task namespace.
static String TRANSIT_PLUGIN_URN
          The constant Transit ANTLIB plugin task namespace.
 
Constructor Summary
TransitComponentHelper(Project project)
          Creation of a new transit component helper.
TransitComponentHelper(Project project, ComponentHelper parent)
          Creation of a new transit component helper.
 
Method Summary
 void buildFinished(BuildEvent event)
          Notification that the build has finished.
 void buildStarted(BuildEvent event)
          Notification that the build has started.
 Object createComponent(String name)
          Create an object for a component using a supplied name.
static void initialize(Project project)
          Creation of a component helper for the supplied project.
static void initialize(Project project, boolean flag)
          Creation of a component helper for the supplied project.
 void messageLogged(BuildEvent event)
          Notification of a message logged.
static void register(MapDataType[] maps)
          Register the mapping between a urn and a plugin uri.
 void setProject(Project project)
          Set the current project.
 void subBuildFinished(BuildEvent event)
          Notification that a sub build has finished.
 void subBuildStarted(BuildEvent event)
          Notification that a sub build has started.
 void targetFinished(BuildEvent event)
          Notification that the build target has finished.
 void targetStarted(BuildEvent event)
          Notification that the build target has started.
 void taskFinished(BuildEvent event)
          Notification that the build task has finaished.
 void taskStarted(BuildEvent event)
          Notification that the build task has started.
 
Methods inherited from class org.apache.tools.ant.ComponentHelper
addDataTypeDefinition, addDataTypeDefinition, addTaskDefinition, checkTaskClass, createComponent, createDataType, createTask, enterAntLib, exitAntLib, getAntTypeTable, getComponentClass, getComponentHelper, getCurrentAntlibUri, getDataTypeDefinitions, getDefinition, getElementName, getNext, getTaskDefinitions, initDefaultDefinitions, initSubProject, setNext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRANSIT_ANTLIB_URN

public static final String TRANSIT_ANTLIB_URN
The constant Transit ANTLIB namespace.

See Also:
Constant Field Values

TRANSIT_INIT_URN

public static final String TRANSIT_INIT_URN
The constant Transit ANTLIB init task namespace.

See Also:
Constant Field Values

TRANSIT_PLUGIN_URN

public static final String TRANSIT_PLUGIN_URN
The constant Transit ANTLIB plugin task namespace.

See Also:
Constant Field Values

TRANSIT_IMPORT_URN

public static final String TRANSIT_IMPORT_URN
The constant Transit ANTLIB import task namespace.

See Also:
Constant Field Values

TRANSIT_GET_URN

public static final String TRANSIT_GET_URN
The constant Transit ANTLIB get task namespace.

See Also:
Constant Field Values

PLUGIN_ARTIFACT_HEADER

public static final String PLUGIN_ARTIFACT_HEADER
The constant artifact plugin header.

See Also:
Constant Field Values
Constructor Detail

TransitComponentHelper

public TransitComponentHelper(Project project)
Creation of a new transit component helper.

Parameters:
project - the current project

TransitComponentHelper

public TransitComponentHelper(Project project,
                              ComponentHelper parent)
Creation of a new transit component helper.

Parameters:
project - the current project
parent - the parent component helper
Method Detail

initialize

public static void initialize(Project project)
Creation of a component helper for the supplied project.

Parameters:
project - the project

initialize

public static void initialize(Project project,
                              boolean flag)
Creation of a component helper for the supplied project.

Parameters:
project - the project
flag - subproject flag

register

public static void register(MapDataType[] maps)
Register the mapping between a urn and a plugin uri.

Parameters:
maps - a sequence of urn to uri bindings

setProject

public void setProject(Project project)
Set the current project.

Parameters:
project - the current ant project

createComponent

public Object createComponent(String name)
Create an object for a component using a supplied name. The name is the fully qualified component name which allows us to intercept specific namespace qualifiers - in this case 'plugin:'. In the event of a plugin namespace we check to see if the plugin for that name is already loaded and it not we proceed with classic transit-based loading of the plugin and registration of plugin classes with the component helper.

Parameters:
name - the name of the component, if the component is in a namespace, the name is prefixed with the namespace uri and ":"
Returns:
the class if found or null if not.

buildStarted

public void buildStarted(BuildEvent event)
                  throws BuildException
Notification that the build has started.

Specified by:
buildStarted in interface BuildListener
Parameters:
event - the build event
Throws:
BuildException - if a build error occurs

subBuildStarted

public void subBuildStarted(BuildEvent event)
Notification that a sub build has started.

Specified by:
subBuildStarted in interface SubBuildListener
Parameters:
event - the build event

subBuildFinished

public void subBuildFinished(BuildEvent event)
Notification that a sub build has finished.

Specified by:
subBuildFinished in interface SubBuildListener
Parameters:
event - the build event

buildFinished

public void buildFinished(BuildEvent event)
Notification that the build has finished.

Specified by:
buildFinished in interface BuildListener
Parameters:
event - the build event

targetStarted

public void targetStarted(BuildEvent event)
Notification that the build target has started.

Specified by:
targetStarted in interface BuildListener
Parameters:
event - the build event

targetFinished

public void targetFinished(BuildEvent event)
Notification that the build target has finished.

Specified by:
targetFinished in interface BuildListener
Parameters:
event - the build event

taskStarted

public void taskStarted(BuildEvent event)
Notification that the build task has started.

Specified by:
taskStarted in interface BuildListener
Parameters:
event - the build event

taskFinished

public void taskFinished(BuildEvent event)
Notification that the build task has finaished.

Specified by:
taskFinished in interface BuildListener
Parameters:
event - the build event

messageLogged

public void messageLogged(BuildEvent event)
Notification of a message logged.

Specified by:
messageLogged in interface BuildListener
Parameters:
event - the build event