org.apache.catalina.ant

Class BaseRedirectorHelperTask

public abstract class BaseRedirectorHelperTask extends 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.

Since: 5.5

Version: $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (Tue, 24 Oct 2006) $

Author: Gabriele Garuglieri

Field Summary
protected booleanalwaysLog
Flag which indicates that, if redirected, output should also be always sent to the log.
protected booleanfailOnError
Whether to fail (with a BuildException) if ManagerServlet returns an error.
protected OutputStreamredirectErrStream
The stream for error output
protected Redirectorredirector
Redirector helper
protected booleanredirectorConfigured
will be set to true when the configuration of the Redirector is complete.
protected RedirectorElementredirectorElement
Redirector element for this task
protected booleanredirectOutput
true true when output redirection is requested for this task .
protected OutputStreamredirectOutStream
The stream for info output
Method Summary
voidaddConfiguredRedirector(RedirectorElement redirectorElement)
Add a RedirectorElement to this task.
protected voidcloseRedirector()
Ask redirector to close all the streams.
protected voidhandleErrorFlush(String output)
Handles error output with the ERR priority and flushes the stream.
protected voidhandleErrorOutput(String output)
Handles error output with the ERR priority.
protected voidhandleFlush(String output)
Handles output with the INFO priority and flushes the stream.
protected voidhandleFlush(String output, int priority)
Handles output with ERR priority to error stream and all other pritorities to output stream, then flushes the stream.
protected voidhandleOutput(String output)
Handles output with the INFO priority.
protected voidhandleOutput(String output, int priority)
Handles output with ERR priority to error stream and all other pritorities 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(File error)
File the error output of the task is redirected to.
voidsetErrorProperty(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(File out)
File the output of the task is redirected to.
voidsetOutputproperty(String outputProperty)
Property name whose value should be set to the output of the task.

Field Detail

alwaysLog

protected boolean alwaysLog
Flag which indicates that, if redirected, output should also be always sent to the log. Default is that otput is sent only to redirected streams.

failOnError

protected 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.

redirectErrStream

protected OutputStream redirectErrStream
The stream for error output

redirector

protected Redirector redirector
Redirector helper

redirectorConfigured

protected boolean redirectorConfigured
will be set to true when the configuration of the Redirector is complete.

redirectorElement

protected RedirectorElement redirectorElement
Redirector element for this task

redirectOutput

protected boolean redirectOutput
true true when output redirection is requested for this task . Default is to log on Ant log.

redirectOutStream

protected OutputStream redirectOutStream
The stream for info output

Method Detail

addConfiguredRedirector

public void addConfiguredRedirector(RedirectorElement redirectorElement)
Add a RedirectorElement to this task.

Parameters: redirectorElement RedirectorElement.

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.

handleErrorFlush

protected void handleErrorFlush(String output)
Handles error output with the ERR priority and flushes the stream.

Parameters: output The error output to log. Should not be null.

handleErrorOutput

protected void handleErrorOutput(String output)
Handles error output with the ERR priority.

Parameters: output The error output to log. Should not be null.

handleFlush

protected void handleFlush(String output)
Handles output with the INFO priority and flushes the stream.

Parameters: output The output to log. Should not be null.

handleFlush

protected void handleFlush(String output, int priority)
Handles output with ERR priority to error stream and all other pritorities to output stream, then flushes the stream.

Parameters: output The output to log. Should not be null.

handleOutput

protected void handleOutput(String output)
Handles output with the INFO priority.

Parameters: output The output to log. Should not be null.

handleOutput

protected void handleOutput(String output, int priority)
Handles output with ERR priority to error stream and all other pritorities to output stream.

Parameters: output The output to log. Should not be null.

isFailOnError

public boolean isFailOnError()
Returns the value of the failOnError property.

openRedirector

protected void openRedirector()
Set up properties on the Redirector and create output streams.

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 the Redirector itself.

Parameters: alwaysLog boolean

setAppend

public void setAppend(boolean append)
If true, append output to existing file.

Parameters: append if true, append output to existing file

setCreateEmptyFiles

public void setCreateEmptyFiles(boolean createEmptyFiles)
Whether output and error files should be created even when empty. Defaults to true.

Parameters: createEmptyFiles boolean.

setError

public void setError(File error)
File the error output of the task is redirected to.

Parameters: error name of the error file

setErrorProperty

public void setErrorProperty(String errorProperty)
Property name whose value should be set to the error of the task..

Parameters: errorProperty property name

setFailonerror

public void setFailonerror(boolean fail)
Whether to fail (with a BuildException) if ManagerServlet returns an error. The default behavior is to do so.

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.

setOutput

public void setOutput(File out)
File the output of the task is redirected to.

Parameters: out name of the output file

setOutputproperty

public void setOutputproperty(String outputProperty)
Property name whose value should be set to the output of the task.

Parameters: outputProperty property name

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.