net.sf.fikin.ant.httpclientanttask
Class BaseResponseAntMethod

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by net.sf.fikin.ant.httpclientanttask.BaseAntMethod
              extended by net.sf.fikin.ant.httpclientanttask.BaseResponseAntMethod
Direct Known Subclasses:
AntDeleteMethod, AntGetMethod, AntHeadMethod, AntMultipartPostMethod, AntOptionsMethod, AntPostMethod, AntPutMethod, AntTraceMethod

public abstract class BaseResponseAntMethod
extends BaseAntMethod

provides basic methods for http-responce logging on top of base response moethod

created on Feb 11, 2006

Since:
Version:
$Revision: 1.5 $
Author:
fiykov

Nested Class Summary
 class BaseResponseAntMethod.ProjectLogOutputStream
           
 class BaseResponseAntMethod.ProjectLogWriter
          Wraps Ant's Project logging into a java.io.Writer interface
 
Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
BaseResponseAntMethod()
           
 
Method Summary
 void after_execute_method()
          after actual execute() strategy method, customize if needed but always call
protected  void check()
          check the consistency of the object call it before calling @link #process(Project, HttpMethod) in order to guarantee a correct execution checks for: logProcessAs is valid and logLevel is valid too
protected  void closeOutput()
          close output stream if applicable
 boolean getLogAppend()
          should append to the log file if exists
 java.io.File getLogFile()
          get the log file to
 java.lang.String getLogLevel()
          get the logging level, one of "none", "all", "content" or "header"
 java.lang.String getLogProcessAs()
          get logging mode, one of "text", "xml" or "binary"
protected  java.io.OutputStream getOutStream()
          get the logging output stream
protected  java.io.Writer getOutWriter()
          get the actual log writer
protected  void initOutputHandler()
          check the settings and create appropriate output handler
protected  void printBytes(byte[] arr, int len)
          print byte array to the output
protected  void printString(java.lang.String str)
          print single string to the output
protected  void processResponse(org.apache.commons.httpclient.HttpMethod method)
          process response stream as indicated by the settings
 void setLogAppend(boolean appendTo)
          do an append to the log file please, by default false
 void setLogFile(java.io.File file)
          set the log file for all the response data
 void setLogLevel(java.lang.String s)
          set the loggin level of the response data one of: heaqder - will log only http-header response data content - will log only the http-response data all - will log both none - will log nothing by default it is "content"
 void setLogProcessAs(java.lang.String s)
          set logging format one of: text - will log as text data xml - will log as markup language binary - will log in a binary mode by default it is "text"
protected  void setOutStream(java.io.OutputStream o)
          assign the actual writer as stream
protected  void setOutWriter(java.io.Writer o)
          assign the actual writer
 
Methods inherited from class net.sf.fikin.ant.httpclientanttask.BaseAntMethod
addProperty, before_execute_method, clearHttpClient, createProxy, createUserCredentials, execute_method, execute, getConnectionTimeout, getCookiePolicy, getFailOnError, getHttpClient, getHttpMethod, getProperties, getProxy, getRetryAttempts, getShutdown, getSslAcceptUntrusted, getUrl, getUserCredentials, newHttpMethod, setConnectionTimeout, setCookiePolicy, setFailOnError, setHttpMethod, setProperties, setProxy, setRetryAttempts, setShutdown, setSslAcceptUntrusted, setUrl, setUserCredentials
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseResponseAntMethod

public BaseResponseAntMethod()
Method Detail

setLogFile

public void setLogFile(java.io.File file)
set the log file for all the response data

Parameters:
file - to log to
Ant Task Param Required:
false

getLogFile

public java.io.File getLogFile()
get the log file to

Returns:
respinse data log file to

setLogAppend

public void setLogAppend(boolean appendTo)
do an append to the log file please, by default false

Parameters:
appendTo - if set to true will append the data if the file exists
Ant Task Param Required:
false

getLogAppend

public boolean getLogAppend()
should append to the log file if exists

Returns:
true if it will append, by default false

setLogLevel

public void setLogLevel(java.lang.String s)
set the loggin level of the response data one of: by default it is "content"

Parameters:
s -
Ant Task Param Required:
false

getLogLevel

public java.lang.String getLogLevel()
get the logging level, one of "none", "all", "content" or "header"

Returns:
logging level, by default "content"

setLogProcessAs

public void setLogProcessAs(java.lang.String s)
set logging format one of: by default it is "text"

Parameters:
s -
Ant Task Param Required:
false

getLogProcessAs

public java.lang.String getLogProcessAs()
get logging mode, one of "text", "xml" or "binary"

Returns:
logging mode, by default it is "text"

setOutWriter

protected void setOutWriter(java.io.Writer o)
assign the actual writer

Parameters:
o -

getOutWriter

protected java.io.Writer getOutWriter()
get the actual log writer

Returns:
writer

setOutStream

protected void setOutStream(java.io.OutputStream o)
assign the actual writer as stream

Parameters:
o -

getOutStream

protected java.io.OutputStream getOutStream()
get the logging output stream

Returns:
output stream

check

protected void check()
              throws org.apache.tools.ant.BuildException
check the consistency of the object call it before calling @link #process(Project, HttpMethod) in order to guarantee a correct execution checks for: logProcessAs is valid and logLevel is valid too

Overrides:
check in class BaseAntMethod
Throws:
org.apache.tools.ant.BuildException

after_execute_method

public void after_execute_method()
                          throws org.apache.tools.ant.BuildException
after actual execute() strategy method, customize if needed but always call

Overrides:
after_execute_method in class BaseAntMethod
Throws:
org.apache.tools.ant.BuildException

processResponse

protected void processResponse(org.apache.commons.httpclient.HttpMethod method)
                        throws org.apache.tools.ant.BuildException,
                               java.io.FileNotFoundException,
                               java.io.IOException
process response stream as indicated by the settings

Throws:
org.apache.tools.ant.BuildException
java.io.FileNotFoundException
java.io.IOException

printString

protected void printString(java.lang.String str)
                    throws java.io.IOException
print single string to the output

Parameters:
str -
Throws:
java.io.IOException

printBytes

protected void printBytes(byte[] arr,
                          int len)
                   throws java.io.IOException
print byte array to the output

Parameters:
arr -
len -
Throws:
java.io.IOException

closeOutput

protected void closeOutput()
                    throws java.io.IOException
close output stream if applicable

Throws:
java.io.IOException

initOutputHandler

protected void initOutputHandler()
                          throws java.io.FileNotFoundException,
                                 java.io.IOException
check the settings and create appropriate output handler

Throws:
java.io.FileNotFoundException
java.io.IOException


Copyright © 2003-2007 Nikolay Fiykov. All Rights Reserved.