|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.httpgw.HTTPResponse
wt.httpgw.HTTPResponseImpl
This class is a carrier of HTTP response information back to an HTTP gateway from a method server. It uses customized serialization code to stream response bodies to the gateway.
Server-side Serialization The server (NetFactor method server) constructs response objects to carry response information back to the gateway. The object contains fields to store response header information, an output stream reference, and a target class and method.
Object serialization stores the RMI marshal stream reference in the object and invokes the target method using Java's reflection API. The target method uses methods on the response object to set response attributes (content-type, status, etc.) and eventually calls a method to retrieve the output stream on which to write the response body. This call causes the response attributes to be written to the marshal stream. When the target method returns, serialization is complete.
Client-side Deserialization The client (HTTP gateway) receives the response object as the return value of a RMI call. It is deserialized before the RMI call completes. In order to support processing of streamed data, the deserialization code looks up the corresponding HTTPGateway object and uses it to send the response directly from the deserialization code.
First the headers are set on the real gateway response, then the content body is forwarded by reading blocks of data from the input stream and writing them to real response output stream until the entire body has been sent.
Note: Four response headers are set by default: Protocol is set to HTTP/1.0; Status is set to 200 (OK); and Content-Type is set to text/html. Expires is set to long ago, the Java epoch - date(0) If you need to set other headers or change these defaults, you must do so in your response processing PRIOR to calling getOutputStream.
Supported API: true
Extendable: false
Field Summary | |
private static int |
BUFSIZ
|
private Integer |
gatewayId
|
private HTTPResponseHeaders |
hdrs
|
private boolean |
hdrsSent
|
private static String |
HOMEPAGE_CLASS
|
private static String |
HOMEPAGE_METHOD
|
private InputStream |
inputStream
|
private ObjectOutput |
objOut
ObjectOutputStream to which Business Classes write responses. |
private String |
remoteHost
|
private static String |
RESOURCE
|
private OutputStream |
responseStream
|
private Object[] |
respTargetArgs
|
private Method |
respTargetMethod
|
(package private) static long |
serialVersionUID
|
private long |
startTime
|
private static boolean |
VERBOSE_CLIENT
|
private static boolean |
VERBOSE_SERVER
|
private static int |
WRITE_TIMEOUT
|
private Thread |
writer
|
Fields inherited from class wt.httpgw.HTTPResponse |
respException |
Constructor Summary | |
HTTPResponseImpl()
Externalizable constructor used on receiving side. |
|
HTTPResponseImpl(Integer gateway_id)
Constructor used on sending side. |
Method Summary | |
boolean |
containsHeader(String s)
Checks if the response header is present. |
Object |
get(String s)
Gets the value of this response header key. |
OutputStream |
getOutputStream()
Called to get the output stream to write the data to. |
Enumeration |
keys()
Gets the response header keys. |
private void |
printException(Throwable t,
boolean traceback)
|
void |
readExternal(ObjectInput input_stream)
|
void |
run()
Run method for write timer thread Supported API: false |
void |
setDateHeader(String s1,
long date)
Sets a date type response header. |
void |
setHeader(String s1,
String s2)
Sets a string type response header. |
void |
setIntHeader(String s1,
int v1)
Sets a int type response header. |
void |
setRemoteHost(String remote_host)
Setter for the remote host that will be displayed in exception tracebacks. |
void |
setRespTarget(Method method,
Object[] args)
Setter for the target method that will generate the real response to the output stream. |
void |
setStatus(int v1)
Sets a simple Status response header. |
void |
setStatus(int v1,
String s1)
Sets a Status response header. |
void |
writeExternal(ObjectOutput output_stream)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
static final long serialVersionUID
private static final String RESOURCE
private static boolean VERBOSE_SERVER
private static boolean VERBOSE_CLIENT
private static int WRITE_TIMEOUT
private static String HOMEPAGE_CLASS
private static String HOMEPAGE_METHOD
private static final int BUFSIZ
private Integer gatewayId
private HTTPResponseHeaders hdrs
private transient boolean hdrsSent
private transient Object[] respTargetArgs
private transient Method respTargetMethod
private transient String remoteHost
private transient ObjectOutput objOut
private transient OutputStream responseStream
private transient long startTime
private transient Thread writer
private transient InputStream inputStream
Constructor Detail |
public HTTPResponseImpl(Integer gateway_id)
public HTTPResponseImpl()
Method Detail |
public OutputStream getOutputStream() throws IOException
getOutputStream
in class HTTPResponse
IOException
- if not marshaling response in writeObject.
the output stream is null until such time.
Also, if the response target class or method is
null. There is not a proper business class or
method to write the response.public void readExternal(ObjectInput input_stream) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
public void writeExternal(ObjectOutput output_stream) throws IOException
writeExternal
in interface Externalizable
IOException
private void printException(Throwable t, boolean traceback)
public void run()
run
in interface Runnable
public void setRespTarget(Method method, Object[] args)
setRespTarget
in class HTTPResponse
method
- is the target business Methodargs
- are the object array of arguments
needed my the target method.public void setRemoteHost(String remote_host)
setRemoteHost
in class HTTPResponse
public boolean containsHeader(String s)
containsHeader
in class HTTPResponse
s
- String the header to search for.
public Enumeration keys()
keys
in class HTTPResponse
public Object get(String s)
get
in class HTTPResponse
s
- the key, as a string, to get the value of.
public void setHeader(String s1, String s2)
setHeader
in class HTTPResponse
s1
- String name of the headers2
- String value to which header is setpublic void setDateHeader(String s1, long date)
setDateHeader
in class HTTPResponse
s1
- String name of the headerdate
- long value to which header is set
value is milliseconds since the epoch.public void setIntHeader(String s1, int v1)
setIntHeader
in class HTTPResponse
s1
- String name of the headerv1
- int value to which header is setpublic void setStatus(int v1)
setStatus
in class HTTPResponse
v1
- Integer Status codepublic void setStatus(int v1, String s1)
setStatus
in class HTTPResponse
v1
- Integer Status codes1
- String Status reason code
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |