Package org.apache.catalina.ant
Class BaseRedirectorHelperTask
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.catalina.ant.BaseRedirectorHelperTask
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
AbstractCatalinaTask
,JMXAccessorTask
,ValidatorTask
public abstract class BaseRedirectorHelperTask
extends org.apache.tools.ant.Task
Abstract base class to add output redirection support for Catalina Ant tasks. These tasks require Ant 1.5 or later.
WARNING: due to depends chain, Ant could call a Task more than once and this can affect the output redirection when configured. If you are collecting the output in a property, it will collect the output of only the first run, since Ant properties are immutable and once created they cannot be changed.
If you are collecting output in a file the file will be overwritten with the output of the last run, unless you set append="true", in which case each run will append it's output to the file.
WARNING: due to depends chain, Ant could call a Task more than once and this can affect the output redirection when configured. If you are collecting the output in a property, it will collect the output of only the first run, since Ant properties are immutable and once created they cannot be changed.
If you are collecting output in a file the file will be overwritten with the output of the last run, unless you set append="true", in which case each run will append it's output to the file.
- Since:
- 5.5
- Author:
- Gabriele Garuglieri
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Flag which indicates that, if redirected, output should also be always sent to the log.protected boolean
Whether to fail (with a BuildException) if ManagerServlet returns an error.protected OutputStream
The stream for error outputprotected final org.apache.tools.ant.taskdefs.Redirector
Redirector helperprotected boolean
will be set totrue
when the configuration of the Redirector is complete.protected org.apache.tools.ant.types.RedirectorElement
Redirector element for this taskprotected boolean
true
true when output redirection is requested for this task.protected OutputStream
The stream for info outputFields 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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addConfiguredRedirector
(org.apache.tools.ant.types.RedirectorElement redirectorElement) Add aRedirectorElement
to this task.protected void
Ask redirector to close all the streams.protected void
handleErrorFlush
(String output) Handles error output with the ERR priority and flushes the stream.protected void
handleErrorOutput
(String output) Handles error output with the ERR priority.protected void
handleFlush
(String output) Handles output with the INFO priority and flushes the stream.protected void
handleOutput
(String output) Handles output with the INFO priority.protected void
handleOutput
(String output, int priority) Handles output with ERR priority to error stream and all other priorities to output stream.boolean
Returns the value of the failOnError property.protected void
Set up properties on the Redirector and create output streams.void
setAlwaysLog
(boolean alwaysLog) If true, (error and non-error) output will be redirected as specified while being sent to Ant's logging mechanism as if no redirection had taken place.void
setAppend
(boolean append) If true, append output to existing file.void
setCreateEmptyFiles
(boolean createEmptyFiles) Whether output and error files should be created even when empty.void
File the error output of the task is redirected to.void
setErrorProperty
(String errorProperty) Property name whose value should be set to the error of the task.void
setFailonerror
(boolean fail) Whether to fail (with a BuildException) if ManagerServlet returns an error.void
setLogError
(boolean logError) Controls whether error output is logged.void
File the output of the task is redirected to.void
setOutputproperty
(String outputProperty) Property name whose value should be set to the output of the task.Methods inherited from class org.apache.tools.ant.Task
bindToOwner, execute, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleInput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
-
Field Details
-
redirector
protected final org.apache.tools.ant.taskdefs.Redirector redirectorRedirector helper -
redirectorElement
protected org.apache.tools.ant.types.RedirectorElement redirectorElementRedirector element for this task -
redirectOutStream
The stream for info output -
redirectErrStream
The stream for error output -
failOnError
protected boolean failOnErrorWhether to fail (with a BuildException) if ManagerServlet returns an error. The default behavior is to do so. This flag does not control parameters checking. If the task is called with wrong or invalid parameters, it will throw BuildException independently from the setting of this flag. -
redirectOutput
protected boolean redirectOutputtrue
true when output redirection is requested for this task. Default is to log on Ant log. -
redirectorConfigured
protected boolean redirectorConfiguredwill be set totrue
when the configuration of the Redirector is complete. -
alwaysLog
protected boolean alwaysLogFlag which indicates that, if redirected, output should also be always sent to the log. Default is that output is sent only to redirected streams.
-
-
Constructor Details
-
BaseRedirectorHelperTask
public BaseRedirectorHelperTask()
-
-
Method Details
-
setFailonerror
public void setFailonerror(boolean fail) Whether to fail (with a BuildException) if ManagerServlet returns an error. The default behavior is to do so.- Parameters:
fail
- The new value of failonerror
-
isFailOnError
public boolean isFailOnError()Returns the value of the failOnError property.- Returns:
true
if the task should will if an error occurs, otherwisefalse
-
setOutput
File the output of the task is redirected to.- Parameters:
out
- name of the output file
-
setError
File the error output of the task is redirected to.- Parameters:
error
- name of the error file
-
setLogError
public void setLogError(boolean logError) Controls whether error output is logged. This is only useful when output is being redirected and error output is desired in the Ant log- Parameters:
logError
- if true the standard error is sent to the Ant log system and not sent to output stream.
-
setOutputproperty
Property name whose value should be set to the output of the task.- Parameters:
outputProperty
- property name
-
setErrorProperty
Property name whose value should be set to the error of the task.- Parameters:
errorProperty
- property name
-
setAppend
public void setAppend(boolean append) If true, append output to existing file.- Parameters:
append
- if true, append output to existing file
-
setAlwaysLog
public void setAlwaysLog(boolean alwaysLog) If true, (error and non-error) output will be redirected as specified while being sent to Ant's logging mechanism as if no redirection had taken place. Defaults to false.
Actually handled internally, with Ant 1.6.3 it will be handled by theRedirector
itself.- Parameters:
alwaysLog
-boolean
-
setCreateEmptyFiles
public void setCreateEmptyFiles(boolean createEmptyFiles) Whether output and error files should be created even when empty. Defaults to true.- Parameters:
createEmptyFiles
-boolean
.
-
addConfiguredRedirector
public void addConfiguredRedirector(org.apache.tools.ant.types.RedirectorElement redirectorElement) Add aRedirectorElement
to this task.- Parameters:
redirectorElement
-RedirectorElement
.
-
openRedirector
protected void openRedirector()Set up properties on the Redirector and create output streams. -
closeRedirector
protected void closeRedirector()Ask redirector to close all the streams. It is necessary to call this method before leaving the Task to have the Streams flush their contents. If you are collecting output in a property, it will be created only if this method is called, otherwise you'll find it unset. -
handleOutput
Handles output with the INFO priority.- Overrides:
handleOutput
in classorg.apache.tools.ant.Task
- Parameters:
output
- The output to log. Should not benull
.
-
handleFlush
Handles output with the INFO priority and flushes the stream.- Overrides:
handleFlush
in classorg.apache.tools.ant.Task
- Parameters:
output
- The output to log. Should not benull
.
-
handleErrorOutput
Handles error output with the ERR priority.- Overrides:
handleErrorOutput
in classorg.apache.tools.ant.Task
- Parameters:
output
- The error output to log. Should not benull
.
-
handleErrorFlush
Handles error output with the ERR priority and flushes the stream.- Overrides:
handleErrorFlush
in classorg.apache.tools.ant.Task
- Parameters:
output
- The error output to log. Should not benull
.
-
handleOutput
Handles output with ERR priority to error stream and all other priorities to output stream.- Parameters:
output
- The output to log. Should not benull
.priority
- The priority level that should be used
-