public class JomcTask extends org.apache.tools.ant.Task
execute()
Type | Property and Description |
---|---|
KeyValueType |
createTransformationOutput
Creates a new
transformationOutputProperty element instance. |
Constructor and Description |
---|
JomcTask()
Creates a new
JomcTask instance. |
Modifier and Type | Method and Description |
---|---|
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. |
protected ExecutorService |
getExecutorService()
Gets the
ExecutorService used to run tasks in parallel. |
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
URL s for a given resource location. |
String |
getThreads()
Gets a formula used to calculate the maximum number of threads to create for running tasks in parallel.
|
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 |
setThreads(String value)
Sets the formula to use to calculate the maximum number of threads to create for running tasks in parallel.
|
void |
setUnless(Object value)
Sets an object controlling the execution of the 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
transformationOutputProperty
element instance.transformationOutputProperty
element instance.getTransformationOutputProperties()
public JomcTask()
JomcTask
instance.public final Object getIf()
null
.setIf(java.lang.Object)
public final void setIf(Object value)
value
- The new object controlling the execution of the task or null
.getIf()
public final Object getUnless()
null
.setUnless(java.lang.Object)
public final void setUnless(Object value)
value
- The new object controlling the execution of the task or null
.getUnless()
public final org.apache.tools.ant.types.Path createClasspath()
classpath
element instance.classpath
element instance.public final org.apache.tools.ant.types.Path getClasspath()
setClasspath(org.apache.tools.ant.types.Path)
public final void setClasspath(org.apache.tools.ant.types.Path value)
value
- The path to add to the list of class path elements.getClasspath()
public final void setClasspathRef(org.apache.tools.ant.types.Reference value)
value
- A reference to a class path.getClasspath()
public final String getModel()
setModel(java.lang.String)
public final void setModel(String value)
value
- The new identifier of the model to process or null
.getModel()
public final List<KeyValueType> getModelContextAttributes()
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.
ModelContext
attributes to apply.createModelContextAttribute()
,
newModelContext(java.lang.ClassLoader)
public KeyValueType createModelContextAttribute()
modelContextAttribute
element instance.modelContextAttribute
element instance.getModelContextAttributes()
public final String getModelContextFactoryClassName()
ModelContextFactory
implementation class backing the task.ModelContextFactory
implementation class backing the task or null
.setModelContextFactoryClassName(java.lang.String)
public final void setModelContextFactoryClassName(String value)
ModelContextFactory
implementation class backing the task.value
- The new name of the ModelContextFactory
implementation class backing the task or
null
.getModelContextFactoryClassName()
public final boolean isModelProcessingEnabled()
true
, if processing of models is enabled; false
, else.setModelProcessingEnabled(boolean)
public final void setModelProcessingEnabled(boolean value)
value
- true
, to enable processing of models; false
, to disable processing of models.isModelProcessingEnabled()
public final String getModletLocation()
null
.setModletLocation(java.lang.String)
public final void setModletLocation(String value)
value
- The new location to search for modlets or null
.getModletLocation()
public final String getModletSchemaSystemId()
http://jomc.org/modlet
namespace schema system id of the context backing the task.http://jomc.org/modlet
namespace schema system id of the context backing the task or
null
.setModletSchemaSystemId(java.lang.String)
public final void setModletSchemaSystemId(String value)
http://jomc.org/modlet
namespace schema system id of the context backing the task.value
- The new http://jomc.org/modlet
namespace schema system id of the context backing the task or
null
.getModletSchemaSystemId()
public final String getProviderLocation()
null
.setProviderLocation(java.lang.String)
public final void setProviderLocation(String value)
value
- The new location to search for providers or null
.getProviderLocation()
public final String getPlatformProviderLocation()
null
.setPlatformProviderLocation(java.lang.String)
public final void setPlatformProviderLocation(String value)
value
- The new location to search for platform provider resources or null
.getPlatformProviderLocation()
public final List<KeyValueType> getTransformationParameters()
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.
createTransformationParameter()
,
getTransformer(org.jomc.ant.types.TransformerResourceType)
public KeyValueType createTransformationParameter()
transformationParameter
element instance.transformationParameter
element instance.getTransformationParameters()
public final List<PropertiesResourceType> getTransformationParameterResources()
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.
createTransformationParameterResource()
,
getTransformer(org.jomc.ant.types.TransformerResourceType)
public PropertiesResourceType createTransformationParameterResource()
transformationParameterResource
element instance.transformationParameterResource
element instance.getTransformationParameterResources()
public final List<KeyValueType> getTransformationOutputProperties()
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.
createTransformationOutputProperty()
public KeyValueType createTransformationOutputProperty()
transformationOutputProperty
element instance.transformationOutputProperty
element instance.getTransformationOutputProperties()
public final boolean isModletResourceValidationEnabled()
true
, if JAXP schema validation of modlet resources is enabled; false
, else.setModletResourceValidationEnabled(boolean)
public final void setModletResourceValidationEnabled(boolean value)
value
- true
, to enable JAXP schema validation of modlet resources; false
, to disable JAXP
schema validation of modlet resources.isModletResourceValidationEnabled()
public final String getThreads()
C
, the number of threads will be calculated by multiplying the value by
the number of available processors. The default number of threads is the number of available processors (1.0C).Runtime.availableProcessors()
public final void setThreads(String value)
C
, the number of threads will be calculated by multiplying the value
by the number of available processors. The default number of threads is the number of available processors
(1.0C).value
- The formula to use to calculate the maximum number of threads or null
, to disable any
parallelism.protected final ExecutorService getExecutorService()
ExecutorService
used to run tasks in parallel.ExecutorService
used to run tasks in parallel or null
, if the maximum number of
threads to create for running tasks in parallel is not greater than 1.public final void execute() throws org.apache.tools.ant.BuildException
execute
in class org.apache.tools.ant.Task
org.apache.tools.ant.BuildException
- if execution fails.getIf()
,
getUnless()
,
preExecuteTask()
,
executeTask()
,
postExecuteTask()
public void preExecuteTask() throws org.apache.tools.ant.BuildException
execute
method prior to the executeTask
method.org.apache.tools.ant.BuildException
- if execution fails.execute()
public void executeTask() throws org.apache.tools.ant.BuildException
execute
method prior to the postExecuteTask
method.org.apache.tools.ant.BuildException
- if execution fails.execute()
public void postExecuteTask() throws org.apache.tools.ant.BuildException
execute
method after the preExecuteTask
/executeTask
methods even if those
methods threw an exception.org.apache.tools.ant.BuildException
- if execution fails.execute()
public Model getModel(ModelContext context) throws ModelException
Model
from a given ModelContext
.context
- The context to get a Model
from.Model
from context
.NullPointerException
- if contexŧ
is null
.ModelException
- if getting the model fails.getModel()
,
isModelProcessingEnabled()
public URL getResource(String location) throws org.apache.tools.ant.BuildException
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.
location
- The resource location to create an URL
from.URL
for location
or null
, if parsing location
to an URL fails and
location
points to a non-existent resource.NullPointerException
- if location
is null
.org.apache.tools.ant.BuildException
- if creating an URL fails.public URL[] getResources(ModelContext context, String location) throws org.apache.tools.ant.BuildException
URL
s 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.
context
- The context to search for resources.location
- The resource location to create an array of URL
s from.URL
s for location
or an empty array if parsing location
to an URL
fails and location
points to non-existent resources.NullPointerException
- if context
or location
is null
.org.apache.tools.ant.BuildException
- if creating an URL array fails.public URL getDirectory(String location) throws org.apache.tools.ant.BuildException
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.
location
- The directory location to create an URL
from.URL
for location
or null
, if parsing location
to an URL fails and
location
points to a non-existent directory.NullPointerException
- if location
is null
.org.apache.tools.ant.BuildException
- if creating an URL fails.public Transformer getTransformer(TransformerResourceType resource) throws TransformerConfigurationException
Transformer
for a given TransformerResourceType
.resource
- The resource to create a Transformer
of.Transformer
for resource
or null
, if resource
is not found and
flagged optional.TransformerConfigurationException
- if creating a new Transformer
fails.getTransformationParameterResources()
,
getTransformationParameters()
,
getResource(java.lang.String)
public Properties getProperties(PropertiesResourceType propertiesResourceType) throws org.apache.tools.ant.BuildException
Properties
instance from a PropertiesResourceType
.propertiesResourceType
- The PropertiesResourceType
specifying the properties to create.propertiesResourceType
.NullPointerException
- if propertiesResourceType
is null
.org.apache.tools.ant.BuildException
- if loading properties fails.public ProjectClassLoader newProjectClassLoader() throws org.apache.tools.ant.BuildException
ProjectClassLoader
instance.ProjectClassLoader
instance.org.apache.tools.ant.BuildException
- if creating a new class loader instance fails.public ModelContext newModelContext(ClassLoader classLoader) throws ModelException
ModelContext
instance using a given class loader.classLoader
- The class loader to create a new ModelContext
instance with.ModelContext
instance backed by classLoader
.ModelException
- if creating a new ModelContext
instance fails.public final void assertNotNull(String attributeName, Object value) throws org.apache.tools.ant.BuildException
BuildException
on a given null
value.attributeName
- The name of a mandatory attribute.value
- The value of that attribute.NullPointerException
- if attributeName
is null
.org.apache.tools.ant.BuildException
- if value
is null
.public final void assertNamesNotNull(Collection<? extends NameType> names) throws org.apache.tools.ant.BuildException
BuildException
on a null
value of a name
property of a given NameType
collection.names
- The collection holding the NameType
instances to test.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.public final void assertKeysNotNull(Collection<? extends KeyValueType> keys) throws org.apache.tools.ant.BuildException
BuildException
on a null
value of a key
property of a given KeyValueType
collection.keys
- The collection holding the KeyValueType
instances to test.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.public final void assertLocationsNotNull(Collection<? extends ResourceType> locations) throws org.apache.tools.ant.BuildException
BuildException
on a null
value of a location
property of a given
ResourceType
collection.locations
- The collection holding the ResourceType
instances to test.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.public final void logSeparator()
public final void logMessage(Level level, String message) throws org.apache.tools.ant.BuildException
level
- The level to log at.message
- The message to log.org.apache.tools.ant.BuildException
- if logging fails.public final void logMessage(Level level, String message, Throwable throwable) throws org.apache.tools.ant.BuildException
level
- The level to log at.message
- The message to log.throwable
- The throwable to log.org.apache.tools.ant.BuildException
- if logging fails.public final void logValidationReport(ModelContext context, ModelValidationReport report)
context
- The context to use for logging the report.report
- The report to log.NullPointerException
- if context
or report
is null
.org.apache.tools.ant.BuildException
- if logging fails.Copyright © 2005–2016 The JOMC Project. All rights reserved.