|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectfr.gouv.culture.sdx.utils.SdxObjectImpl
fr.gouv.culture.sdx.utils.rdbms.JDBC
fr.gouv.culture.sdx.utils.rdbms.DataSourceComponentBacked
fr.gouv.culture.sdx.repository.AbstractDataSourceComponentBackedRepository
fr.gouv.culture.sdx.repository.JDBCRepository
An implementation of a repository using a JDBC datasource.
This repository can be used by itself, or be subclassed for specific RDBMS. A great care has been taken to isolate what could be vendor specific.
Nested Class Summary |
Nested classes inherited from class fr.gouv.culture.sdx.utils.rdbms.JDBC |
JDBC.QueryExecutor, JDBC.Template |
Field Summary | |
protected static java.lang.String |
FIELD_DATA
Constant for a field name in a table |
static int |
NO_SPECIFIC_TYPE
|
protected int |
PARAM_INDEX_FIELD_DATA_ORIGINAL
|
Fields inherited from class fr.gouv.culture.sdx.repository.AbstractDataSourceComponentBackedRepository |
FIELD_ID, isDefault, PARAM_INDEX_FIELD_ID, props |
Fields inherited from class fr.gouv.culture.sdx.utils.rdbms.DataSourceComponentBacked |
ATTRIBUTE_DSI, dbSelector, dsi, manager |
Fields inherited from class fr.gouv.culture.sdx.utils.rdbms.JDBC |
id, tableName |
Fields inherited from class fr.gouv.culture.sdx.utils.SdxObjectImpl |
encoding, logger |
Fields inherited from interface fr.gouv.culture.sdx.repository.Repository |
ATTRIBUTE_DEFAULT, ATTRIBUTE_ID, ATTRIBUTE_REF, ATTRIBUTE_TYPE, CLASS_NAME_SUFFIX, ELEMENT_NAME_REPOSITORIES, ELEMENT_NAME_REPOSITORY, PACKAGE_QUALNAME |
Constructor Summary | |
JDBCRepository()
Creates a repository. |
Method Summary | |
void |
add(Document doc,
RepositoryConnection c)
Adds a document to the repository. |
void |
compose(org.apache.avalon.framework.component.ComponentManager manager)
Compose the object so that we get the Component s we need from the
ComponentManager . |
void |
configure(org.apache.avalon.framework.configuration.Configuration configuration)
Configures this repository. |
void |
delete(Document doc,
RepositoryConnection c)
Deletes a document from the repository. |
void |
empty()
Deletes all documents from the repository. |
void |
get(Document doc,
java.io.OutputStream os,
RepositoryConnection c)
Writes the content of a document to an output stream. |
RepositoryConnection |
getConnection()
Gets a connection for manipulating repository's content. |
protected java.lang.String |
getDeleteAllQuery()
Returns an SQL query that could delete all documents. |
protected java.lang.String |
getDocumentAddQuery()
Returns an SQL query that could add a document. |
protected java.lang.String |
getDocumentDeleteQuery()
Returns an SQL query that could delete a document. |
protected java.lang.String |
getTableCreationQuery()
Returns an SQL query that could create the table. |
void |
init()
Initializes the repository. |
void |
lists(org.xml.sax.ContentHandler hdl)
Lists the repository content as SAX events. |
java.io.InputStream |
openStream(Document doc,
java.lang.String encoding,
RepositoryConnection c)
Opens an input stream to read the content of a document. |
void |
releaseConnection(RepositoryConnection c)
Releases a previously opened connection. |
long |
size()
Returns the number of documents within the repository (all kind of documents). |
void |
toSAX(ParsableDocument doc,
org.apache.cocoon.xml.XMLConsumer consumer,
RepositoryConnection c)
Retrieves an SDX document as SAX events. |
Methods inherited from class fr.gouv.culture.sdx.repository.AbstractDataSourceComponentBackedRepository |
checkConnection, checkEncoding, exists, getDocumentGetQuery, getId, isDefault, loadBaseConfiguration, optimize, setIsDefault, setProperties |
Methods inherited from class fr.gouv.culture.sdx.utils.rdbms.DataSourceComponentBacked |
getDataSourceComponent, releaseDataSourceComponent |
Methods inherited from class fr.gouv.culture.sdx.utils.rdbms.JDBC |
createTable, getTableName, handleUnsupportedTokens |
Methods inherited from class fr.gouv.culture.sdx.utils.SdxObjectImpl |
enableLogging, getChildLogger, setEncoding |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled |
enableLogging |
Field Detail |
public static final int NO_SPECIFIC_TYPE
protected static final java.lang.String FIELD_DATA
protected final int PARAM_INDEX_FIELD_DATA_ORIGINAL
Constructor Detail |
public JDBCRepository()
A logger must be set and then this repository must be configured and initialized.
SdxObjectImpl.enableLogging(org.apache.avalon.framework.logger.Logger)
,
configure(org.apache.avalon.framework.configuration.Configuration)
,
init()
Method Detail |
public RepositoryConnection getConnection() throws SDXException
SDXException
public void releaseConnection(RepositoryConnection c) throws SDXException
c
- A connection.
SDXException
public void compose(org.apache.avalon.framework.component.ComponentManager manager) throws org.apache.avalon.framework.component.ComponentException
Component
s we need from the
ComponentManager
.
compose
in interface org.apache.avalon.framework.component.Composable
compose
in class DataSourceComponentBacked
manager
- The component manager from Cocoon that allow us to acquire a database selector component.
org.apache.avalon.framework.component.ComponentException
public void configure(org.apache.avalon.framework.configuration.Configuration configuration) throws org.apache.avalon.framework.configuration.ConfigurationException
In addition to the parameters needed in the base configuration handled by the parent class, the following parameter is required: data source identifier (dsi), the value of the "name" attribute of the "jdbc" subElement for the "datasources" element in cocoon.xconf (user must create this information in cocoon.xconf)
configure
in interface org.apache.avalon.framework.configuration.Configurable
configure
in class AbstractDataSourceComponentBackedRepository
configuration
- The configuration for this repository (based on a xml file).
Sample configuration entry:
<sdx:repository sdx:type = "JDBC" sdx:id = "myRepoId" dsi = "datasource identifier from cocoon.xconf"/>
org.apache.avalon.framework.configuration.ConfigurationException
public void init() throws SDXException
SDXException
public long size() throws SDXException
SDXException
public void lists(org.xml.sax.ContentHandler hdl) throws SDXException
The exact structure is still to be defined, but it should be very simple, with only one element per document and a few properties as attributes.
hdl
- A SAX content handler to feed with events.
SDXException
public void add(Document doc, RepositoryConnection c) throws SDXException
add
in interface Repository
add
in class AbstractDataSourceComponentBackedRepository
doc
- A document.c
- A connection to the repository.
SDXException
public void empty() throws SDXException
SDXException
public void delete(Document doc, RepositoryConnection c) throws SDXException
delete
in interface Repository
delete
in class AbstractDataSourceComponentBackedRepository
doc
- A document.c
- A connection to the repository.
SDXException
public void toSAX(ParsableDocument doc, org.apache.cocoon.xml.XMLConsumer consumer, RepositoryConnection c) throws SDXException
toSAX
in interface Repository
toSAX
in class AbstractDataSourceComponentBackedRepository
doc
- A ParsableDocument, ie XMLDocument or HTMLDocument.consumer
- A SAX content handler to feed with events.
The wrapped contentHandler for including events within an XSP page contentHandler should be created using IncludeXMLConsumer stripper = new IncludeXMLConsumer(xspContentHandler);
c
- A connection to the repository.
SDXException
public java.io.InputStream openStream(Document doc, java.lang.String encoding, RepositoryConnection c) throws SDXException
openStream
in interface Repository
openStream
in class AbstractDataSourceComponentBackedRepository
encoding
- An encoding (may be null).
If null
or invalid we use a default.
TODOImplement use of encoding currently not implemented , will do soon.
doc
- A document to read.c
- A connection to the repository.
SDXException
public void get(Document doc, java.io.OutputStream os, RepositoryConnection c) throws SDXException
get
in interface Repository
get
in class AbstractDataSourceComponentBackedRepository
doc
- A document.os
- An output stream.c
- A connection to the repository.
SDXException
protected java.lang.String getTableCreationQuery()
This query should not have any parameter.
getTableCreationQuery
in class JDBC
protected java.lang.String getDocumentAddQuery()
This query should have three parameters, the first for the id, the second for the doctype and the third for the data.
protected java.lang.String getDocumentDeleteQuery()
This query should have one parameter for the document's id.
protected java.lang.String getDeleteAllQuery()
This query should not have any parameter.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |