|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--org.apache.tools.ant.ProjectComponent
|
+--org.apache.tools.ant.Task
|
+--org.apache.anteater.test.BaseTask
|
+--org.apache.anteater.test.ContentHandlerTask
|
+--org.apache.anteater.test.SendResponse
Sends an HTTP response back in the servlet thread.
This task looks in the object model for a stored HttpServletResponse and
Writer, which it uses to write the response.
See here for a description of how this interacts with other classes.
| Field Summary | |
protected String |
body
|
protected String |
contentType
|
protected List |
headers
|
protected String |
href
|
protected Map |
objectModel
|
protected int |
responseCode
|
| Fields inherited from class org.apache.anteater.test.ContentHandlerTask |
handlerFactory, matcherTests |
| Fields inherited from class org.apache.anteater.test.BaseTask |
debug, debugWasSet |
| 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 |
| Fields inherited from interface org.apache.anteater.test.ObjectModel |
NAMESPACES_KEY, PROPERTIES_KEY |
| Constructor Summary | |
SendResponse()
|
|
| Method Summary | |
void |
addText(String text)
Sets the body text. |
void |
execute()
Retrieves the HttpServletResponse and Writer, and uses the
contents of the file specified by setHref(java.lang.String) to write a response. |
String |
getContent(Object obj)
Handle body tasks through the ContentHandler interface. |
String[] |
getHandledTypes()
Specify the body tasks we are able to handle. |
String |
getHref()
|
String |
getText()
Retrieves the body text. |
void |
init()
|
void |
setContentType(String contentType)
Set MIME content type to label body contents as. |
void |
setHref(String href)
Set the path of the file whose contents will constitute the HTTP body returned to the caller. |
void |
setObjectModel(Map objectModel)
Set the context in the receiving object. |
void |
setResponseCode(int code)
Set the HTTP response code to send to the client. |
void |
writeTo(javax.servlet.http.HttpServletResponse response,
Writer responseWriter)
Sends a response back to the HTTP client. |
| Methods inherited from class org.apache.anteater.test.ContentHandlerTask |
addTask |
| Methods inherited from class org.apache.anteater.test.BaseTask |
debug, getDebug, getGroup, print, println, resolveContentURL, setDebug, setGroup, setGroup |
| Methods inherited from class org.apache.tools.ant.Task |
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorOutput, handleOutput, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName |
| 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 |
| Field Detail |
protected String body
protected String href
protected String contentType
protected int responseCode
protected List headers
protected Map objectModel
| Constructor Detail |
public SendResponse()
| Method Detail |
public void init()
init in class org.apache.tools.ant.Taskpublic String[] getHandledTypes()
getHandledTypes in interface ContentHandler
public String getContent(Object obj)
throws Exception
ContentHandler interface.
We can't use the normal addConfiguredXxx methods because we want to
maintain backwards-compat with the 0.9.11 ability to define the HTTP body
as nested text.
getContent in interface ContentHandlerobj - An object that the ContentHandler implementation knows how to
process. Typically an Ant task.
null, which represents 'no content'.
Exceptionpublic void setHref(String href)
href - Path to a filepublic String getHref()
public void addText(String text)
throws org.apache.tools.ant.BuildException
addText in class ContentHandlerTaskorg.apache.tools.ant.BuildException
public String getText()
throws org.apache.tools.ant.BuildException
org.apache.tools.ant.BuildExceptionpublic void setContentType(String contentType)
contentType - MIME
type, eg text/html or text/plain.
public void setResponseCode(int code)
throws org.apache.tools.ant.BuildException
code - HTTP
response code, eg 200 (OK), 400 (Bad request), 404 (Not Found).
org.apache.tools.ant.BuildExceptionpublic void setObjectModel(Map objectModel)
ObjectModel
setObjectModel in interface ObjectModelobjectModel - a HashMap value
public void writeTo(javax.servlet.http.HttpServletResponse response,
Writer responseWriter)
throws IOException,
org.apache.tools.ant.BuildException
response - The HttpServletResponse set by the servlet. This will have it's content type and status set.responseWriter - a Writer, which will send bytes through an inter-thread pipe to the servlet, and then on to the client as the response body.
IOException
org.apache.tools.ant.BuildException
public void execute()
throws org.apache.tools.ant.BuildException
HttpServletResponse and Writer, and uses the
contents of the file specified by setHref(java.lang.String) to write a response.
execute in class ContentHandlerTaskorg.apache.tools.ant.BuildException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||