wt.httpgw
Class HTTPGateway

java.lang.Object
  extended bywt.httpgw.HTTPGateway

public class HTTPGateway
extends Object

The HTTPGateway class represents the conduit between the Web server and the NetFactor method server. It includes a main method allowing it to serve as a CGI application, but can also be used within a Servlet. This class is responsible for abstracting the CGI/Servlet role so NetFactor method servers need not be aware of the difference. A new instance is created for each request. The object's purpose is to allow the unmarshaling of a HTTPResponse object to bind itself back to the corresponding request during unmarshaling. This is necessary to support streaming responses through the gateway during response deserialization. It is accomplished by assigning each instance a lookup id that is passed to the method server along with the request. The response includes this id and is used to find the corresponding instance while the response object is still be deserialized. The response deserialization code can then set response headers and access the body output stream directly. An instance-based lookup is required so that multiple requests can be handled simultaneously by a multi-threaded Servlet.

The HTTP request is forwarded to a method server by wrapping the request (including entity body input stream) in a HTTPRequest object and passing that object as an argument to the processRequest method of the HTTPServer class. Special argument and response serialization code handles streaming of request input and output so when the called method returns, there is no further work to be performed.


Field Summary
private  boolean aborted
           
private  boolean addHeaders
           
private  Properties cgiData
           
private static String CLASS
           
(package private) static Hashtable gateways
           
private  Integer id
           
private  InputStream inputStream
           
 boolean invalidateSession
           
private static String METHOD
           
(package private) static int nextGatewayId
           
private  OutputStream outputStream
           
private  Object servletWriter
           
private static boolean VERBOSE
           
private static int VERBOSITY
           
 
Constructor Summary
HTTPGateway(InputStream input_stream, Object gateway_writer)
          Creates a new HTTPGateway initialized with the specified input stream and object.
HTTPGateway(InputStream input_stream, OutputStream output_stream)
          Creates a new HTTPGateway initialized with the specified input stream and output stream.
 
Method Summary
 void abort(Thread writer)
          Abort response.
static HTTPGateway get(Integer id)
          Gets the HTTPGateway object by index (int).
 InputStream getInputStream()
          Gets the input stream associated with this HTTPGateway object.
 OutputStream getOutputStream()
          Gets the output stream associated with this HTTPGateway object.
private  OutputStream getServletOutputStream()
           
 void processRequest(HTTPRequest request)
          Process request received from the client.
 void setAddHeaders(boolean addHeaders)
          Sets the flag that be used to decide if the HTTP Response Headers are written to the OutputStream
private  void setServletHTMLHeader()
           
 void writeHdrs(HTTPResponseHeaders headers)
          Sends the writeHeaders method in HTTPResponseHeaders the proper sink to write to.
private  void writeServletHdrs(HTTPResponseHeaders headers)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS

private static final String CLASS

METHOD

private static final String METHOD

VERBOSE

private static final boolean VERBOSE

VERBOSITY

private static final int VERBOSITY

gateways

static Hashtable gateways

nextGatewayId

static int nextGatewayId

cgiData

private Properties cgiData

inputStream

private InputStream inputStream

outputStream

private OutputStream outputStream

id

private Integer id

servletWriter

private Object servletWriter

aborted

private boolean aborted

invalidateSession

public boolean invalidateSession

addHeaders

private boolean addHeaders
Constructor Detail

HTTPGateway

public HTTPGateway(InputStream input_stream,
                   Object gateway_writer)
Creates a new HTTPGateway initialized with the specified input stream and object. This is the constructor used by our HTTPGatewayServlet.

Parameters:
input_stream - the input stream
gateway_writer - the object

HTTPGateway

public HTTPGateway(InputStream input_stream,
                   OutputStream output_stream)
Creates a new HTTPGateway initialized with the specified input stream and output stream. This is the constructor used by our HTTPGateway main in conjuction with our CGI wrapper WTCGI.EXE.

Parameters:
input_stream - the input stream
output_stream - the output stream
Method Detail

get

public static HTTPGateway get(Integer id)
Gets the HTTPGateway object by index (int).

Parameters:
id - the index int of our HTTPGateway object
Returns:
A HTTPGateway object.

getInputStream

public InputStream getInputStream()
Gets the input stream associated with this HTTPGateway object.

Returns:
An InputStream.

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Gets the output stream associated with this HTTPGateway object.

Returns:
An OutputStream.
Throws:
IOException

writeHdrs

public void writeHdrs(HTTPResponseHeaders headers)
               throws IOException
Sends the writeHeaders method in HTTPResponseHeaders the proper sink to write to.

Throws:
IOException

writeServletHdrs

private void writeServletHdrs(HTTPResponseHeaders headers)

abort

public void abort(Thread writer)
Abort response. Used by writer timeout in HTTPResponse.


processRequest

public void processRequest(HTTPRequest request)
                    throws IOException
Process request received from the client. This is the RMI stub.

Throws:
IOException

setServletHTMLHeader

private void setServletHTMLHeader()
                           throws IOException
Throws:
IOException

getServletOutputStream

private OutputStream getServletOutputStream()
                                     throws IOException
Throws:
IOException

setAddHeaders

public void setAddHeaders(boolean addHeaders)
Sets the flag that be used to decide if the HTTP Response Headers are written to the OutputStream

Parameters:
addHeaders - sets flag