|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.reading.AbstractReader
org.apache.cocoon.reading.ServiceableReader
org.apache.cocoon.reading.DatabaseReader
public class DatabaseReader
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.
| Field Summary |
|---|
| Fields inherited from class org.apache.cocoon.reading.ServiceableReader |
|---|
manager |
| Fields inherited from class org.apache.cocoon.reading.AbstractReader |
|---|
objectModel, out, parameters, resolver, source |
| Fields inherited from interface org.apache.cocoon.reading.Reader |
|---|
ROLE |
| Constructor Summary | |
|---|---|
DatabaseReader()
|
|
| Method Summary | |
|---|---|
void |
configure(Configuration conf)
Configure the Reader so that we can use the same database
for all instances. |
void |
dispose()
|
void |
generate()
Generates the resource we need to retrieve verbatim from the database. |
Serializable |
getKey()
Generate the unique key. |
String |
getMimeType()
Get the mime-type of the output of this Reader |
protected String |
getQuery()
This method builds the query string used for accessing the database. |
SourceValidity |
getValidity()
Generate the validity object. |
protected boolean |
modifiedSince(ResultSet set,
Request request,
Response response)
Tests whether a resource has been modified or not. |
void |
recycle()
Recycle the component |
void |
serialize(Response response)
This method actually performs the serialization. |
void |
service(ServiceManager manager)
|
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. |
| Methods inherited from class org.apache.cocoon.reading.AbstractReader |
|---|
getLastModified, setOutputStream, shouldSetContentLength |
| Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
|---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DatabaseReader()
| Method Detail |
|---|
public void service(ServiceManager manager)
throws ServiceException
service in interface Serviceableservice in class ServiceableReaderServiceExceptionServiceable.service(org.apache.avalon.framework.service.ServiceManager)
public void configure(Configuration conf)
throws ConfigurationException
Reader so that we can use the same database
for all instances.
configure in interface ConfigurableConfigurationException
public void setup(SourceResolver resolver,
Map objectModel,
String src,
Parameters par)
throws ProcessingException,
SAXException,
IOException
SourceResolver the object model Map,
the source and sitemap Parameters used to process the request.
setup in interface SitemapModelComponentsetup in class AbstractReaderProcessingException
SAXException
IOException
public void generate()
throws ProcessingException,
SAXException,
IOException
<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.
generate in interface ReaderProcessingException
SAXException
IOException
protected String getQuery()
throws ProcessingException
ProcessingException
protected boolean modifiedSince(ResultSet set,
Request request,
Response response)
throws SQLException
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.
SQLException
public void serialize(Response response)
throws IOException,
SQLException
IOException
SQLExceptionpublic Serializable getKey()
getKey in interface CacheableProcessingComponentpublic SourceValidity getValidity()
getValidity in interface CacheableProcessingComponentnull if the
component is currently not cacheable.public void recycle()
AbstractReader
recycle in interface Recyclablerecycle in class AbstractReaderpublic void dispose()
dispose in interface Disposablepublic String getMimeType()
AbstractReaderReader
getMimeType in interface SitemapOutputComponentgetMimeType in class AbstractReaderAbstractProcessingPipeline.setMimeTypeForSerializer(org.apache.cocoon.environment.Environment),
AbstractProcessingPipeline.setMimeTypeForReader(org.apache.cocoon.environment.Environment)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||