org.jomc.ant
Class JomcTask

Package class diagram package JomcTask
java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.jomc.ant.JomcTask
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
JomcModelTask, MergeModletsTask

public class JomcTask
extends org.apache.tools.ant.Task

Base class for executing tasks.

Version:
$JOMC: JomcTask.java 4204 2012-01-26 08:33:42Z schulte2005 $
Author:
Christian Schulte
See Also:
execute()

Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
JomcTask()
          Creates a new JomcTask instance.
 
Method Summary
 void assertKeysNotNull(Collection<? extends KeyValueType> keys)
          Throws a BuildException on a null value of a key property of a given KeyValueType collection.
 void assertLocationsNotNull(Collection<? extends ResourceType> locations)
          Throws a BuildException on a null value of a location property of a given ResourceType collection.
 void assertNamesNotNull(Collection<? extends NameType> names)
          Throws a BuildException on a null value of a name property of a given NameType collection.
 void assertNotNull(String attributeName, Object value)
          Throws a BuildException on a given null value.
 JomcTask clone()
          Creates and returns a copy of this object.
 org.apache.tools.ant.types.Path createClasspath()
          Creates a new classpath element instance.
 KeyValueType createModelContextAttribute()
          Creates a new modelContextAttribute element instance.
 KeyValueType createTransformationOutputProperty()
          Creates a new transformationOutputProperty element instance.
 KeyValueType createTransformationParameter()
          Creates a new transformationParameter element instance.
 PropertiesResourceType createTransformationParameterResource()
          Creates a new transformationParameterResource element instance.
 void execute()
          Called by the project to let the task do its work.
 void executeTask()
          Called by the execute method prior to the postExecuteTask method.
 org.apache.tools.ant.types.Path getClasspath()
          Gets the class path to process.
 URL getDirectory(String location)
          Creates an URL for a given directory location.
 Object getIf()
          Gets an object controlling the execution of the task.
 String getModel()
          Gets the identifier of the model to process.
 Model getModel(ModelContext context)
          Gets a Model from a given ModelContext.
 List<KeyValueType> getModelContextAttributes()
          Gets the ModelContext attributes to apply.
 String getModelContextFactoryClassName()
          Gets the name of the ModelContextFactory implementation class backing the task.
 String getModletLocation()
          Gets the location searched for modlets.
 String getModletSchemaSystemId()
          Gets the http://jomc.org/modlet namespace schema system id of the context backing the task.
 String getPlatformProviderLocation()
          Gets the location searched for platform provider resources.
 Properties getProperties(PropertiesResourceType propertiesResourceType)
          Creates a new Properties instance from a PropertiesResourceType.
 String getProviderLocation()
          Gets the location searched for providers.
 URL getResource(String location)
          Creates an URL for a given resource location.
 URL[] getResources(ModelContext context, String location)
          Creates an array of URLs for a given resource location.
 List<KeyValueType> getTransformationOutputProperties()
          Gets the global transformation output properties to apply.
 List<PropertiesResourceType> getTransformationParameterResources()
          Gets the global transformation parameter resources to apply.
 List<KeyValueType> getTransformationParameters()
          Gets the global transformation parameters to apply.
 Transformer getTransformer(TransformerResourceType resource)
          Creates a new Transformer for a given TransformerResourceType.
 Object getUnless()
          Gets an object controlling the execution of the task.
 boolean isModelProcessingEnabled()
          Gets a flag indicating the processing of models is enabled.
 boolean isModletResourceValidationEnabled()
          Gets a flag indicating JAXP schema validation of modlet resources is enabled.
 void logMessage(Level level, String message)
          Logs a message at a given level.
 void logMessage(Level level, String message, Throwable throwable)
          Logs a message at a given level.
 void logSeparator()
          Logs a separator string.
 void logValidationReport(ModelContext context, ModelValidationReport report)
          Logs a validation report.
 ModelContext newModelContext(ClassLoader classLoader)
          Creates a new ModelContext instance using a given class loader.
 ProjectClassLoader newProjectClassLoader()
          Creates a new ProjectClassLoader instance.
 void postExecuteTask()
          Called by the execute method after the preExecuteTask/executeTask methods even if those methods threw an exception.
 void preExecuteTask()
          Called by the execute method prior to the executeTask method.
 void setClasspath(org.apache.tools.ant.types.Path value)
          Adds to the class path to process.
 void setClasspathRef(org.apache.tools.ant.types.Reference value)
          Adds a reference to a class path defined elsewhere.
 void setIf(Object value)
          Sets an object controlling the execution of the task.
 void setModel(String value)
          Sets the identifier of the model to process.
 void setModelContextFactoryClassName(String value)
          Sets the name of the ModelContextFactory implementation class backing the task.
 void setModelProcessingEnabled(boolean value)
          Sets the flag indicating the processing of models is enabled.
 void setModletLocation(String value)
          Sets the location to search for modlets.
 void setModletResourceValidationEnabled(boolean value)
          Sets the flag indicating JAXP schema validation of modlet resources is enabled.
 void setModletSchemaSystemId(String value)
          Sets the http://jomc.org/modlet namespace schema system id of the context backing the task.
 void setPlatformProviderLocation(String value)
          Sets the location to search for platform provider resources.
 void setProviderLocation(String value)
          Sets the location to search for providers.
 void setUnless(Object value)
          Sets an object controlling the execution of the task.
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JomcTask

public JomcTask()
Creates a new JomcTask instance.

Method Detail

getIf

public final Object getIf()
Gets an object controlling the execution of the task.

Returns:
An object controlling the execution of the task or null.
See Also:
setIf(java.lang.Object)

setIf

public final void setIf(Object value)
Sets an object controlling the execution of the task.

Parameters:
value - The new object controlling the execution of the task or null.
See Also:
getIf()

getUnless

public final Object getUnless()
Gets an object controlling the execution of the task.

Returns:
An object controlling the execution of the task or null.
See Also:
setUnless(java.lang.Object)

setUnless

public final void setUnless(Object value)
Sets an object controlling the execution of the task.

Parameters:
value - The new object controlling the execution of the task or null.
See Also:
getUnless()

createClasspath

public final org.apache.tools.ant.types.Path createClasspath()
Creates a new classpath element instance.

Returns:
A new classpath element instance.

getClasspath

public final org.apache.tools.ant.types.Path getClasspath()
Gets the class path to process.

Returns:
The class path to process.
See Also:
setClasspath(org.apache.tools.ant.types.Path)

setClasspath

public final void setClasspath(org.apache.tools.ant.types.Path value)
Adds to the class path to process.

Parameters:
value - The path to add to the list of class path elements.
See Also:
getClasspath()

setClasspathRef

public final void setClasspathRef(org.apache.tools.ant.types.Reference value)
Adds a reference to a class path defined elsewhere.

Parameters:
value - A reference to a class path.
See Also:
getClasspath()

getModel

public final String getModel()
Gets the identifier of the model to process.

Returns:
The identifier of the model to process.
See Also:
setModel(java.lang.String)

setModel

public final void setModel(String value)
Sets the identifier of the model to process.

Parameters:
value - The new identifier of the model to process or null.
See Also:
getModel()

getModelContextAttributes

public final List<KeyValueType> getModelContextAttributes()
Gets the ModelContext attributes to apply.

This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the object. This is why there is no set method for the model context attributes property.

Returns:
The ModelContext attributes to apply.
See Also:
createModelContextAttribute(), newModelContext(java.lang.ClassLoader)

createModelContextAttribute

public KeyValueType createModelContextAttribute()
Creates a new modelContextAttribute element instance.

Returns:
A new modelContextAttribute element instance.
See Also:
getModelContextAttributes()

getModelContextFactoryClassName

public final String getModelContextFactoryClassName()
Gets the name of the ModelContextFactory implementation class backing the task.

Returns:
The name of the ModelContextFactory implementation class backing the task or null.
See Also:
setModelContextFactoryClassName(java.lang.String)

setModelContextFactoryClassName

public final void setModelContextFactoryClassName(String value)
Sets the name of the ModelContextFactory implementation class backing the task.

Parameters:
value - The new name of the ModelContextFactory implementation class backing the task or null.
See Also:
getModelContextFactoryClassName()

isModelProcessingEnabled

public final boolean isModelProcessingEnabled()
Gets a flag indicating the processing of models is enabled.

Returns:
true, if processing of models is enabled; false, else.
See Also:
setModelProcessingEnabled(boolean)

setModelProcessingEnabled

public final void setModelProcessingEnabled(boolean value)
Sets the flag indicating the processing of models is enabled.

Parameters:
value - true, to enable processing of models; false, to disable processing of models.
See Also:
isModelProcessingEnabled()

getModletLocation

public final String getModletLocation()
Gets the location searched for modlets.

Returns:
The location searched for modlets or null.
See Also:
setModletLocation(java.lang.String)

setModletLocation

public final void setModletLocation(String value)
Sets the location to search for modlets.

Parameters:
value - The new location to search for modlets or null.
See Also:
getModletLocation()

getModletSchemaSystemId

public final String getModletSchemaSystemId()
Gets the http://jomc.org/modlet namespace schema system id of the context backing the task.

Returns:
The http://jomc.org/modlet namespace schema system id of the context backing the task or null.
See Also:
setModletSchemaSystemId(java.lang.String)

setModletSchemaSystemId

public final void setModletSchemaSystemId(String value)
Sets the http://jomc.org/modlet namespace schema system id of the context backing the task.

Parameters:
value - The new http://jomc.org/modlet namespace schema system id of the context backing the task or null.
See Also:
getModletSchemaSystemId()

getProviderLocation

public final String getProviderLocation()
Gets the location searched for providers.

Returns:
The location searched for providers or null.
See Also:
setProviderLocation(java.lang.String)

setProviderLocation

public final void setProviderLocation(String value)
Sets the location to search for providers.

Parameters:
value - The new location to search for providers or null.
See Also:
getProviderLocation()

getPlatformProviderLocation

public final String getPlatformProviderLocation()
Gets the location searched for platform provider resources.

Returns:
The location searched for platform provider resources or null.
See Also:
setPlatformProviderLocation(java.lang.String)

setPlatformProviderLocation

public final void setPlatformProviderLocation(String value)
Sets the location to search for platform provider resources.

Parameters:
value - The new location to search for platform provider resources or null.
See Also:
getPlatformProviderLocation()

getTransformationParameters

public final List<KeyValueType> getTransformationParameters()
Gets the global transformation parameters to apply.

This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the object. This is why there is no set method for the transformation parameters property.

Returns:
The global transformation parameters to apply.
See Also:
createTransformationParameter(), getTransformer(org.jomc.ant.types.TransformerResourceType)

createTransformationParameter

public KeyValueType createTransformationParameter()
Creates a new transformationParameter element instance.

Returns:
A new transformationParameter element instance.
See Also:
getTransformationParameters()

getTransformationParameterResources

public final List<PropertiesResourceType> getTransformationParameterResources()
Gets the global transformation parameter resources to apply.

This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the object. This is why there is no set method for the transformation parameter resources property.

Returns:
The global transformation parameter resources to apply.
See Also:
createTransformationParameterResource(), getTransformer(org.jomc.ant.types.TransformerResourceType)

createTransformationParameterResource

public PropertiesResourceType createTransformationParameterResource()
Creates a new transformationParameterResource element instance.

Returns:
A new transformationParameterResource element instance.
See Also:
getTransformationParameterResources()

getTransformationOutputProperties

public final List<KeyValueType> getTransformationOutputProperties()
Gets the global transformation output properties to apply.

This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the object. This is why there is no set method for the transformation output properties property.

Returns:
The global transformation output properties to apply.
See Also:
createTransformationOutputProperty()

createTransformationOutputProperty

public KeyValueType createTransformationOutputProperty()
Creates a new transformationOutputProperty element instance.

Returns:
A new transformationOutputProperty element instance.
See Also:
getTransformationOutputProperties()

isModletResourceValidationEnabled

public final boolean isModletResourceValidationEnabled()
Gets a flag indicating JAXP schema validation of modlet resources is enabled.

Returns:
true, if JAXP schema validation of modlet resources is enabled; false, else.
See Also:
setModletResourceValidationEnabled(boolean)

setModletResourceValidationEnabled

public final void setModletResourceValidationEnabled(boolean value)
Sets the flag indicating JAXP schema validation of modlet resources is enabled.

Parameters:
value - true, to enable JAXP schema validation of modlet resources; false, to disable JAXP schema validation of modlet resources.
See Also:
isModletResourceValidationEnabled()

execute

public final void execute()
                   throws org.apache.tools.ant.BuildException
Called by the project to let the task do its work.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException - if execution fails.
See Also:
getIf(), getUnless(), preExecuteTask(), executeTask(), postExecuteTask()

preExecuteTask

public void preExecuteTask()
                    throws org.apache.tools.ant.BuildException
Called by the execute method prior to the executeTask method.

Throws:
org.apache.tools.ant.BuildException - if execution fails.
See Also:
execute()

executeTask

public void executeTask()
                 throws org.apache.tools.ant.BuildException
Called by the execute method prior to the postExecuteTask method.

Throws:
org.apache.tools.ant.BuildException - if execution fails.
See Also:
execute()

postExecuteTask

public void postExecuteTask()
                     throws org.apache.tools.ant.BuildException
Called by the execute method after the preExecuteTask/executeTask methods even if those methods threw an exception.

Throws:
org.apache.tools.ant.BuildException - if execution fails.
See Also:
execute()

getModel

public Model getModel(ModelContext context)
               throws ModelException
Gets a Model from a given ModelContext.

Parameters:
context - The context to get a Model from.
Returns:
The Model from context.
Throws:
NullPointerException - if contexŧ is null.
ModelException - if getting the model fails.
See Also:
getModel(), isModelProcessingEnabled()

getResource

public URL getResource(String location)
                throws org.apache.tools.ant.BuildException
Creates an URL for a given resource location.

This method first searches the class path of the task for a single resource matching location. If such a resource is found, the URL of that resource is returned. If no such resource is found, an attempt is made to parse the given location to an URL. On successful parsing, that URL is returned. Failing that, the given location is interpreted as a file name relative to the project's base directory. If that file is found, the URL of that file is returned. Otherwise null is returned.

Parameters:
location - The resource location to create an URL from.
Returns:
An URL for location or null, if parsing location to an URL fails and location points to a non-existent resource.
Throws:
NullPointerException - if location is null.
org.apache.tools.ant.BuildException - if creating an URL fails.

getResources

public URL[] getResources(ModelContext context,
                          String location)
                   throws org.apache.tools.ant.BuildException
Creates an array of URLs for a given resource location.

This method first searches the given context for resources matching location. If such resources are found, an array of URLs of those resources is returned. If no such resources are found, an attempt is made to parse the given location to an URL. On successful parsing, that URL is returned. Failing that, the given location is interpreted as a file name relative to the project's base directory. If that file is found, the URL of that file is returned. Otherwise an empty array is returned.

Parameters:
context - The context to search for resources.
location - The resource location to create an array of URLs from.
Returns:
An array of URLs for location or an empty array if parsing location to an URL fails and location points to non-existent resources.
Throws:
NullPointerException - if context or location is null.
org.apache.tools.ant.BuildException - if creating an URL array fails.

getDirectory

public URL getDirectory(String location)
                 throws org.apache.tools.ant.BuildException
Creates an URL for a given directory location.

This method first attempts to parse the given location to an URL. On successful parsing, that URL is returned. Failing that, the given location is interpreted as a directory name relative to the project's base directory. If that directory is found, the URL of that directory is returned. Otherwise null is returned.

Parameters:
location - The directory location to create an URL from.
Returns:
An URL for location or null, if parsing location to an URL fails and location points to a non-existent directory.
Throws:
NullPointerException - if location is null.
org.apache.tools.ant.BuildException - if creating an URL fails.

getTransformer

public Transformer getTransformer(TransformerResourceType resource)
                           throws TransformerConfigurationException
Creates a new Transformer for a given TransformerResourceType.

Parameters:
resource - The resource to create a Transformer of.
Returns:
A new Transformer for resource or null, if resource is not found and flagged optional.
Throws:
TransformerConfigurationException - if creating a new Transformer fails.
See Also:
getTransformationParameterResources(), getTransformationParameters(), getResource(java.lang.String)

getProperties

public Properties getProperties(PropertiesResourceType propertiesResourceType)
                         throws org.apache.tools.ant.BuildException
Creates a new Properties instance from a PropertiesResourceType.

Parameters:
propertiesResourceType - The PropertiesResourceType specifying the properties to create.
Returns:
The properties for propertiesResourceType.
Throws:
NullPointerException - if propertiesResourceType is null.
org.apache.tools.ant.BuildException - if loading properties fails.

newProjectClassLoader

public ProjectClassLoader newProjectClassLoader()
                                         throws org.apache.tools.ant.BuildException
Creates a new ProjectClassLoader instance.

Returns:
A new ProjectClassLoader instance.
Throws:
org.apache.tools.ant.BuildException - if creating a new class loader instance fails.

newModelContext

public ModelContext newModelContext(ClassLoader classLoader)
                             throws ModelException
Creates a new ModelContext instance using a given class loader.

Parameters:
classLoader - The class loader to create a new ModelContext instance with.
Returns:
A new ModelContext instance backed by classLoader.
Throws:
ModelException - if creating a new ModelContext instance fails.

assertNotNull

public final void assertNotNull(String attributeName,
                                Object value)
                         throws org.apache.tools.ant.BuildException
Throws a BuildException on a given null value.

Parameters:
attributeName - The name of a mandatory attribute.
value - The value of that attribute.
Throws:
NullPointerException - if attributeName is null.
org.apache.tools.ant.BuildException - if value is null.

assertNamesNotNull

public final void assertNamesNotNull(Collection<? extends NameType> names)
                              throws org.apache.tools.ant.BuildException
Throws a BuildException on a null value of a name property of a given NameType collection.

Parameters:
names - The collection holding the NameType instances to test.
Throws:
NullPointerException - if names is null.
org.apache.tools.ant.BuildException - if a name property of a given NameType from the names collection holds a null value.

assertKeysNotNull

public final void assertKeysNotNull(Collection<? extends KeyValueType> keys)
                             throws org.apache.tools.ant.BuildException
Throws a BuildException on a null value of a key property of a given KeyValueType collection.

Parameters:
keys - The collection holding the KeyValueType instances to test.
Throws:
NullPointerException - if keys is null.
org.apache.tools.ant.BuildException - if a key property of a given KeyValueType from the keys collection holds a null value.

assertLocationsNotNull

public final void assertLocationsNotNull(Collection<? extends ResourceType> locations)
                                  throws org.apache.tools.ant.BuildException
Throws a BuildException on a null value of a location property of a given ResourceType collection.

Parameters:
locations - The collection holding the ResourceType instances to test.
Throws:
NullPointerException - if locations is null.
org.apache.tools.ant.BuildException - if a location property of a given ResourceType from the locations collection holds a null value.

logSeparator

public final void logSeparator()
Logs a separator string.


logMessage

public final void logMessage(Level level,
                             String message)
                      throws org.apache.tools.ant.BuildException
Logs a message at a given level.

Parameters:
level - The level to log at.
message - The message to log.
Throws:
org.apache.tools.ant.BuildException - if logging fails.

logMessage

public final void logMessage(Level level,
                             String message,
                             Throwable throwable)
                      throws org.apache.tools.ant.BuildException
Logs a message at a given level.

Parameters:
level - The level to log at.
message - The message to log.
throwable - The throwable to log.
Throws:
org.apache.tools.ant.BuildException - if logging fails.

logValidationReport

public final void logValidationReport(ModelContext context,
                                      ModelValidationReport report)
Logs a validation report.

Parameters:
context - The context to use for logging the report.
report - The report to log.
Throws:
NullPointerException - if context or report is null.
org.apache.tools.ant.BuildException - if logging fails.

clone

public JomcTask clone()
Creates and returns a copy of this object.

Overrides:
clone in class org.apache.tools.ant.ProjectComponent
Returns:
A copy of this object.


Copyright © 2005-2012 The JOMC Project. All Rights Reserved.Get JOMC at SourceForge.net. Fast, secure and Free Open Source software downloads
Please note that this documentation is maintained by non-native english speaking authors. As such, you may encounter phrases or wordings which seem imprecise or may even have a totally different meaning to native english speaking readers than what the individual author was trying to express. If you are a native english speaking reader and find any such phrases or wordings we kindly ask you to send an email to the corresponding author and help us improve this documentation in order to avoid misunderstandings. You will find the authors' email addresses at the top of each class. Please accept our apologies for any inconvenience caused.