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:
- java.lang.Cloneable
 - Direct Known Subclasses:
- AbstractCatalinaTask,- JMXAccessorTask,- ValidatorTask
 
 public abstract class BaseRedirectorHelperTask extends org.apache.tools.ant.TaskAbstract 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.- Since:
- 5.5
- Author:
- Gabriele Garuglieri
 
- 
- 
Field SummaryFields Modifier and Type Field Description protected booleanalwaysLogFlag which indicates that, if redirected, output should also be always sent to the log.protected booleanfailOnErrorWhether to fail (with a BuildException) if ManagerServlet returns an error.protected java.io.OutputStreamredirectErrStreamThe stream for error outputprotected org.apache.tools.ant.taskdefs.RedirectorredirectorRedirector helperprotected booleanredirectorConfiguredwill be set totruewhen the configuration of the Redirector is complete.protected org.apache.tools.ant.types.RedirectorElementredirectorElementRedirector element for this taskprotected booleanredirectOutputtruetrue when output redirection is requested for this task.protected java.io.OutputStreamredirectOutStreamThe stream for info output
 - 
Constructor SummaryConstructors Constructor Description BaseRedirectorHelperTask()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConfiguredRedirector(org.apache.tools.ant.types.RedirectorElement redirectorElement)Add aRedirectorElementto this task.protected voidcloseRedirector()Ask redirector to close all the streams.protected voidhandleErrorFlush(java.lang.String output)Handles error output with the ERR priority and flushes the stream.protected voidhandleErrorOutput(java.lang.String output)Handles error output with the ERR priority.protected voidhandleFlush(java.lang.String output)Handles output with the INFO priority and flushes the stream.protected voidhandleOutput(java.lang.String output)Handles output with the INFO priority.protected voidhandleOutput(java.lang.String output, int priority)Handles output with ERR priority to error stream and all other priorities to output stream.booleanisFailOnError()Returns the value of the failOnError property.protected voidopenRedirector()Set up properties on the Redirector and create output streams.voidsetAlwaysLog(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.voidsetAppend(boolean append)If true, append output to existing file.voidsetCreateEmptyFiles(boolean createEmptyFiles)Whether output and error files should be created even when empty.voidsetError(java.io.File error)File the error output of the task is redirected to.voidsetErrorProperty(java.lang.String errorProperty)Property name whose value should be set to the error of the task.voidsetFailonerror(boolean fail)Whether to fail (with a BuildException) if ManagerServlet returns an error.voidsetLogError(boolean logError)Controls whether error output is logged.voidsetOutput(java.io.File out)File the output of the task is redirected to.voidsetOutputproperty(java.lang.String outputProperty)Property name whose value should be set to the output of the task.- 
Methods inherited from class org.apache.tools.ant.TaskbindToOwner, execute, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleInput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
- 
 
- 
- 
- 
Field Detail- 
redirectorprotected final org.apache.tools.ant.taskdefs.Redirector redirector Redirector helper
 - 
redirectorElementprotected org.apache.tools.ant.types.RedirectorElement redirectorElement Redirector element for this task
 - 
redirectOutStreamprotected java.io.OutputStream redirectOutStream The stream for info output
 - 
redirectErrStreamprotected java.io.OutputStream redirectErrStream The stream for error output
 - 
failOnErrorprotected boolean failOnError Whether 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.
 - 
redirectOutputprotected boolean redirectOutput truetrue when output redirection is requested for this task. Default is to log on Ant log.
 - 
redirectorConfiguredprotected boolean redirectorConfigured will be set totruewhen the configuration of the Redirector is complete.
 - 
alwaysLogprotected boolean alwaysLog Flag which indicates that, if redirected, output should also be always sent to the log. Default is that output is sent only to redirected streams.
 
- 
 - 
Method Detail- 
setFailonerrorpublic 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
 
 - 
isFailOnErrorpublic boolean isFailOnError() Returns the value of the failOnError property.- Returns:
- trueif the task should will if an error occurs, otherwise- false
 
 - 
setOutputpublic void setOutput(java.io.File out) File the output of the task is redirected to.- Parameters:
- out- name of the output file
 
 - 
setErrorpublic void setError(java.io.File error) File the error output of the task is redirected to.- Parameters:
- error- name of the error file
 
 - 
setLogErrorpublic 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.
 
 - 
setOutputpropertypublic void setOutputproperty(java.lang.String outputProperty) Property name whose value should be set to the output of the task.- Parameters:
- outputProperty- property name
 
 - 
setErrorPropertypublic void setErrorProperty(java.lang.String errorProperty) Property name whose value should be set to the error of the task.- Parameters:
- errorProperty- property name
 
 - 
setAppendpublic void setAppend(boolean append) If true, append output to existing file.- Parameters:
- append- if true, append output to existing file
 
 - 
setAlwaysLogpublic 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 theRedirectoritself.- Parameters:
- alwaysLog-- boolean
 
 - 
setCreateEmptyFilespublic void setCreateEmptyFiles(boolean createEmptyFiles) Whether output and error files should be created even when empty. Defaults to true.- Parameters:
- createEmptyFiles-- boolean.
 
 - 
addConfiguredRedirectorpublic void addConfiguredRedirector(org.apache.tools.ant.types.RedirectorElement redirectorElement) Add aRedirectorElementto this task.- Parameters:
- redirectorElement-- RedirectorElement.
 
 - 
openRedirectorprotected void openRedirector() Set up properties on the Redirector and create output streams.
 - 
closeRedirectorprotected 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.
 - 
handleOutputprotected void handleOutput(java.lang.String output) Handles output with the INFO priority.- Overrides:
- handleOutputin class- org.apache.tools.ant.Task
- Parameters:
- output- The output to log. Should not be- null.
 
 - 
handleFlushprotected void handleFlush(java.lang.String output) Handles output with the INFO priority and flushes the stream.- Overrides:
- handleFlushin class- org.apache.tools.ant.Task
- Parameters:
- output- The output to log. Should not be- null.
 
 - 
handleErrorOutputprotected void handleErrorOutput(java.lang.String output) Handles error output with the ERR priority.- Overrides:
- handleErrorOutputin class- org.apache.tools.ant.Task
- Parameters:
- output- The error output to log. Should not be- null.
 
 - 
handleErrorFlushprotected void handleErrorFlush(java.lang.String output) Handles error output with the ERR priority and flushes the stream.- Overrides:
- handleErrorFlushin class- org.apache.tools.ant.Task
- Parameters:
- output- The error output to log. Should not be- null.
 
 - 
handleOutputprotected void handleOutput(java.lang.String output, int priority)Handles output with ERR priority to error stream and all other priorities to output stream.- Parameters:
- output- The output to log. Should not be- null.
- priority- The priority level that should be used
 
 
- 
 
-