WBI 4.5 DK API Documentation
Overview of the WBI 4.5 DK packages.
See:
Description
Overview of the WBI 4.5 DK packages.
The WBI Development Kit provides a convenient and flexible API for
programming intermediaries on the web. Such an intermediary is called a WBI plugin.
This document lists the classes that will help get you started
writing your own WBI plugins. This overview is not meant to be
a detailed description of the WBI architecture nor is it a WBI
programming guide. For more details on how to program with
WBI, see
WBI Overview,
WBI Programming, and
WBI Architecture.
For information on how to use some of the classes and packages,
take a look at our sample WBI plugins:
The source code for these examples is part of the WBI DK and can be found in
the <WBI_root_directory>/com/ibm/wbi/examples.
Useful Classes
-
Plugin,
HttpPlugin
Plugin is the the base class for each WBI plugin. There
are four states of a plugin, which correspond to four method calls: initialize(String), enable(),
disable() and terminate(String). HttpPlugin should be used
as the base class for your own WBI plugins as it was specifically designed for HTTP requests.
-
Meg
A Meg is a component within a WBI plugin that can monitor, edit, or generate requests.
WBI plugins register and initialize Megs. If a request satisfies a Meg's condition, then
that Meg is invoked by calling its handleRequest() method.
-
HttpGenerator,
HttpEditor,
HttpRequestEditor,
HttpMonitor
These represent the four basic types of Megs. A HttpRequestEditor can edit the
request before it gets to the Generator. A HttpGenerator can create
the response satisfying a request.
An HttpEditor can
edit the response produced by a generator. A HttpMonitor can
listen to the response at any of four points: after a specific HttpGenerator;
after a specific HttpEditor; before all HttpEditors; or after all HttpEditors.
A HttpMonitor cannot modify the request or response
in any way. Each type of Meg is invoked when WBI calls its
handleRequest() method. See also
com.ibm.wbi.protocol.http.beans, which
contains a set of useful and higher-level Megs classes.
-
RequestEvent
A request is responsible for dispatching the required Megs to
modify or generate a response. A request lives as long as at
least one Meg is still processing the request. A request has an
associated request event that is passed to each Meg and which
contains the input and output streams, as well as any associated
Meg data.
-
MegInputStream,
MegOutputStream
These streams contain the data of a request. A Meg can access this data by reading from
the Meg's input stream. The Meg can analyze and copy this data to the Meg's output stream,
modify the data, or simply throw away the data. Note: If an editor reads from the input
stream but does not write anything back to the output stream,
subsequent Megs in the processing chain will receive an empty
input stream.
-
RequestInfo,
DocumentInfo
These two classes contain structure and header information about a request, such as the URL, the content type, and
the content length. Whereas a RequestInfo object is a generic object, the class
DocumentInfo was specifically designed for HTTP requests.
-
HttpHeader,
HttpRequest,
HttpResponse
These classes are used to manipulate HTTP request, response, or header information from a request.
Their APIs are designed to help programmers easily manipulate HTTP requests and then write them
back to the current request through a DocumentInfo instance.
WBI Packages
-
com.ibm.wbi
This package contains all the basic WBI classes since repackaging whereas in the old WBI version (4.1),
this package only contained
Proxy class, WBI's main class.
This package now contains the classes that represent the input/output streams associated with
a request event. A MEG uses the classes contained in this package to read/write data from/to
a request.
Furthermore, com.ibm.wbi contains the abstract base classes for plugins and the various Megs.
It also
contains the RequestEvent class. Look at this
package to get a basic idea of the plugin-Meg
architecture and the objects the Megs work on, especially the classes that specify the objects
associated with requests, such as Request and RequestInfo.
-
com.ibm.wbi.protocol.http
This package contains classes specifically designed to handle HTTP-related information,
such as HTTP headers, requests, and responses. A very useful class is
FetchUrl, which contains several
static methods for using WBI to open streams to URLs on the web.
Some methods use GET, whereas others take a whole request header to open
simple connections. There are also methods that open connections through WBI, thus going through
the Megs that are registered and enabled.
-
com.ibm.wbi.protocol.http.beans
The beans package holds a set of higher-level Megs that make WBI programming
a lot easier. Check out the specific Megs for local file access
(FileGenerator)
or producing HTML documents
(e.g., StaticHtmlGenerator,
HtmlTemplateGenerator and
HtmlGenerator).
-
com.ibm.wbi.protocol.http
This package contains a set of Meg base classes for handling
HTTP. For example, the class HttpGenerator provides APIs to read/write HTTP responses
(see getHttpResponse()).
This package also contains the class DocumentInfo, which was specifically designed to handle
information associated with an HTTP request.
-
com.ibm.wbi.markuplanguage.html
This package contains a set of classes that were specifically designed to handle HTML sources.
Using these classes, programmers can parse HTML contained in the response and modify the HTML before
it is written back to the output stream.
-
com.ibm.wbi.util
This package contains useful utilities for WBI programming.
-
com.ibm.wbi.persistent
This package contains classes that allow the persistent storage of information.
This replaces the database classes of previous WBI DK versions (package com/ibm/pvccommon/util).
See class Section for details.