Logo of Bento frameworkspaceObject Oriented Programming


JBuilder 2007

RequestStore

Free source code example for Bento framework...

Seeing is believing! First of all, please enjoy the example of Bento framework that is running on our web site. It is the simple photo Blog where you can upload the image files by your web browser (multipart/form-data), or e-mail with file attachment. After you grasp how it works, please explore its source code. The source code of the example is included in the FREE trial version of Bento framework.

[ Try and download example ... ]

Introduction ...

RequestStore is Java API to save the HTTP request parameters into the SQL table. The unique ID is issued for each persisted HTTP request, and this ID can be used to retrieve the request parameters from the SQL table. Please click the links below and look into the source code examples:

[ Source code for INSERT ... ]
[ Source code for SELECT ... ]

You may wonder how this API creates the SQL statement for INSERT/SELECT. In this API, there is no trick to create the SQL statement automatically. The configuration XML of RequestStore defines SQL statements along with the names of request parameters to be stored/selected. And each SQL statement can be indentified by the unique ID. Please click the link below and look into the example XML:

[ Example XML for RequestStore ... ]

Based on the configuration XML like this, RequestStore can decide which SQL statement to use. This is why the source code is free from the SQL statement.

How to use return value ...

As you see in the source code fragment in the above example, RequestStore implements:

method that returns StoredRequestParameters object. RequestStore also implements:

method, that encapsulates the parameters in several HTTP requests into a single StoredRequestParameters object. Because StoredRequestParameters implements a set of getXX methods, your Servlet can get the parameter values explicitly. But, if you are going to include the parameter values into the HTTP response, you no longer need to play with each parameter by getXX method.

The best usage is to pass StoredRequestParameters object to ViewGenerator API. When the HTTP request parameters are selected from SQL table, each parameter value is pushed into StoredRequestParameters object in the form of byte[ ], not in the form of String. To get this byte[ ], ViewGenerator API calls:

method on StoredRequestParameters object. And ViewGenerator API writes the byte[ ] into OutputStream for the HTTP response, without creating the new String for each parameter value. By this way, you can avoid byte-to-character conversion, and your Servlet can get better response.

Mapping between Java and SQL column ...

You may wonder how this API maps the Java object and the column on the SQL table. For example, all the request parameters are available as:

but their corresponding columns on the SQL table are not always CHAR type or its variants. Again, there is no trick to map them automatically. Another configuration XML of RequestStore defines the relationship between them.

[ Example of Map4String.properties ... ]

The value in this property file is the fully qualified class name for:

The implementation of this interface is responsible for calling:

and its source code will look like below:

[ For String ... ]
[ For int ... ]
[ For long ... ]

By this way, you have a full control over the mapping between Java object (or primitive type) and column on the SQL table.

Note that only one instance is created for each class, even the same class name appear repeatedly in Map4String.properties . For example, you will find many

in the above example, but only one instance of this class is created. And this single instance will be used for many columns in more than one SQL statement. So, it is required to make each class Thread Safe.

Read Java doc / FREE Download

You can read the Java doc for this API online. Or it is included in the trial version of this API and you can download it at FREE.

Java doc README
Trial License Product License (PDF)
Download

Copyright © 1997-2008 OOP-Research CorporationTM, All Rights Reserved.

Valid XHTML 1.0! Valid CSS!