com.ibm.wbi.protocol.http.beans
Class FourStepHttpGenerator

com.ibm.wbi.Meg
  |
  +--com.ibm.wbi.Generator
        |
        +--com.ibm.wbi.protocol.http.HttpGenerator
              |
              +--com.ibm.wbi.protocol.http.beans.FourStepHttpGenerator
Direct Known Subclasses:
ErrorPageGenerator, FileGenerator, HtmlGenerator, PageMovedGenerator, ResourceGenerator

public class FourStepHttpGenerator
extends HttpGenerator

This class breaks down the response to an HTTP request into four steps, each of which can be overridden by extending classes.

  1. initialize -- called at the beginning of each transaction
  2. verify -- checks to see if this request should be handled by this Generator or not.
  3. getHeader -- produces the HTTP header string that will be delivered to the browser.
  4. writeContent -- writes the HTTP content to the RequestEvent's output stream.


    Fields inherited from class com.ibm.wbi.protocol.http.HttpGenerator
    COPYRIGHT, http
     
    Fields inherited from class com.ibm.wbi.Meg
    EDITOR, GENERATOR, MONITOR, REQUEST_EDITOR, UNDEFINED
     
    Constructor Summary
    FourStepHttpGenerator()
              Construct a new four step HTTP generator.
     
    Method Summary
    protected  java.lang.String getHeader(RequestEvent e)
              Called third, should return the HTTP response header string.
     void handleRequest(RequestEvent e)
              This method is called by the Proxy.
    protected  void initialize(RequestEvent e)
              Called first, override if you need to prepare for the transaction by setting up some class variables.
    protected  boolean verify(RequestEvent e)
              Called second, override if you wish to check some set of conditions.
    protected  void writeContent(RequestEvent e)
              Called fourth, should write the appropriate data into the output stream object on the request event.
     
    Methods inherited from class com.ibm.wbi.protocol.http.HttpGenerator
    add, addCookie, getContentType, getHttpResponse, getHttpResponseString, getResponseCode, getResponseText, isCache, produceHeader, set, setCache, setContentLength, setContentType, setResponseCode, setResponseText, setServer, writeHeader
     
    Methods inherited from class com.ibm.wbi.Generator
    getType
     
    Methods inherited from class com.ibm.wbi.Meg
    forwardRequest, getCondition, getEnabled, getMegProperty, getMegProperty, getMegPropertyKeys, getName, getPlugin, getPriority, getSystemContext, initialize, initialize, isEnabled, isMegApplicable, loadMegResources, run, setCondition, setEnabled, setMegProperty, setName, setPriority, setSystemContext, setup, setup, setup, setup
     

    Constructor Detail

    FourStepHttpGenerator

    public FourStepHttpGenerator()
    Construct a new four step HTTP generator.
    Method Detail

    initialize

    protected void initialize(RequestEvent e)
    Called first, override if you need to prepare for the transaction by setting up some class variables.
    Parameters:
    e - The request event.

    verify

    protected boolean verify(RequestEvent e)
    Called second, override if you wish to check some set of conditions.
    Returns:
    true to accept this request and handle it [default]
    false to reject this request and let someone else handle it

    getHeader

    protected java.lang.String getHeader(RequestEvent e)
    Called third, should return the HTTP response header string. By default, this returns the HTTP header produced from the parent's HTTPGenerator HTTPResponse object.

    writeContent

    protected void writeContent(RequestEvent e)
                         throws java.io.IOException,
                                RequestRejectedException
    Called fourth, should write the appropriate data into the output stream object on the request event.

    handleRequest

    public void handleRequest(RequestEvent e)
                       throws RequestRejectedException,
                              java.io.IOException
    This method is called by the Proxy. It calls initialize(), verify(), produceHeader() and writeContent() in order.
    Overrides:
    handleRequest in class HttpGenerator
    Throws:
    RequestRejectedException - thrown if verify(RequestEvent) returns false or getHeader(RequestEvent) returns null.
    java.io.IOException - thrown if writing the data has a problem