| org.apache.cocoon.reading.AbstractReader org.apache.cocoon.reading.ServiceableReader org.apache.cocoon.reading.DatabaseReader
DatabaseReader | public class DatabaseReader extends ServiceableReader implements Configurable,Disposable,CacheableProcessingComponent(Code) | | This Reader pulls a resource from a database. It is configured with
the Connection to use, parameters specify the table and column
to pull the image from, and source specifies the source key information.
author: Berin Loritsch version: CVS $Id: DatabaseReader.java 452159 2006-10-02 18:20:45Z vgritsenko $ |
Method Summary | |
public void | configure(Configuration conf) Configure the Reader so that we can use the same database
for all instances. | public void | dispose() | public void | generate() Generates the resource we need to retrieve verbatim from the
database. | public java.io.Serializable | getKey() Generate the unique key. | public String | getMimeType() | protected String | getQuery() This method builds the query string used for accessing the database. | public SourceValidity | getValidity() Generate the validity object. | protected boolean | modifiedSince(ResultSet set, Request request, Response response) Tests whether a resource has been modified or not. | public void | recycle() | public void | serialize(Response response) This method actually performs the serialization. | public void | service(ServiceManager manager) | public void | setup(SourceResolver resolver, Map objectModel, String src, Parameters par) Set the SourceResolver the object model Map ,
the source and sitemap Parameters used to process the request. |
configure | public void configure(Configuration conf) throws ConfigurationException(Code) | | Configure the Reader so that we can use the same database
for all instances.
|
dispose | public void dispose()(Code) | | |
generate | public void generate() throws ProcessingException, SAXException, IOException(Code) | | Generates the resource we need to retrieve verbatim from the
database. Granted, this can be used for any resource from a
database, so we may want to get rid of the bias toward images.
This reader requires a number of parameters:
<parameter name="table" value="database_table_name"/>
<parameter name="image" value="database_resource_column_name"/>
<parameter name="key" value="database_lookup_key_column_name"/>
Please note that if any of those parameters are missing, this
Reader cannot function. There are a number of other
parameters that allow you to provide hints for the reader to
optimize resource use:
<parameter name="last-modified" value="database_timestamp_column_name"/>
<parameter name="content-type" value="content_mime_type"/>
<parameter name="type-column" value="database_content_mime_type_column"/>
<parameter name="expires" value="number_of_millis_before_refresh"/>
<parameter name="where" value="alternate_key = 'foo'"/>
<parameter name="order-by" value="alternate_key DESC"/>
Lastly, the key value is derived from the value of
the source string.
|
getKey | public java.io.Serializable getKey()(Code) | | Generate the unique key.
This key must be unique inside the space of this component.
The generated key hashes the src |
getQuery | protected String getQuery() throws ProcessingException(Code) | | This method builds the query string used for accessing the database.
If the required parameters do not exist, then we cannot build a
correct query.
|
getValidity | public SourceValidity getValidity()(Code) | | Generate the validity object.
The generated validity object or null if thecomponent is currently not cacheable. |
modifiedSince | protected boolean modifiedSince(ResultSet set, Request request, Response response) throws SQLException(Code) | | Tests whether a resource has been modified or not. As Blobs and
database columns usually do not have intrinsic dates on them (at
least easily accessible), we have to have a database column that
holds a date for the resource. Please note, that the database
column must be a Timestamp column.
In the absence of such a column this method always
returns true . This is because databases are much
more prone to change than filesystems, and don't have intrinsic
timestamps on column updates.
|
recycle | public void recycle()(Code) | | |
service | public void service(ServiceManager manager) throws ServiceException(Code) | | |
Fields inherited from org.apache.cocoon.reading.ServiceableReader | protected ServiceManager manager(Code)(Java Doc)
|
Methods inherited from org.apache.cocoon.reading.ServiceableReader | public void service(ServiceManager manager) throws ServiceException(Code)(Java Doc)
|
|
|