|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fr.gouv.culture.sdx.utils.AbstractSdxObject 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
public class 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/interfaces inherited from class fr.gouv.culture.sdx.utils.rdbms.JDBC |
---|
JDBC.QueryExecutor, JDBC.Template |
Nested classes/interfaces inherited from interface fr.gouv.culture.sdx.repository.Repository |
---|
Repository.ConfigurationNode |
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 |
Fields inherited from class fr.gouv.culture.sdx.utils.rdbms.DataSourceComponentBacked |
---|
ATTRIBUTE_DSI, dbSelector, dsi |
Fields inherited from class fr.gouv.culture.sdx.utils.rdbms.JDBC |
---|
tableName |
Fields inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject |
---|
_configuration, _context, _description, _encoding, _id, _locale, _logger, _manager, _xmlizable_objects, _xmlLang, isToSaxInitialized |
Fields inherited from interface fr.gouv.culture.sdx.repository.Repository |
---|
CLASS_NAME_SUFFIX, PACKAGE_QUALNAME |
Fields inherited from interface fr.gouv.culture.sdx.utils.Encodable |
---|
DEFAULT_ENCODING |
Fields inherited from interface fr.gouv.culture.sdx.utils.save.Saveable |
---|
ALL_SAVE_ATTRIB, PATH_ATTRIB, SAVE_DIRECTORY_PARAM |
Constructor Summary | |
---|---|
JDBCRepository()
Creates a repository. |
Method Summary | |
---|---|
void |
add(Document doc,
RepositoryConnection c)
Adds a document to the repository. |
void |
backup(SaveParameters save_config)
Save the repository |
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 |
getEntriesWithLimitQuery(long offset,
long number)
Implementation of statement with a limit parameter No limit there, implementation is done in the subclasses. |
protected java.lang.String |
getTableCreationQuery()
Returns an SQL query that could create the table. |
void |
init()
Initializes the repository. |
protected boolean |
initToSax()
Init the LinkedHashMap _xmlizable_objects with the objects in order to describ them in XML |
protected void |
initVolatileObjectsToSax()
Init the LinkedHashMap _xmlizable_volatile_objects with the objects in order to describ them in XML Some objects need to be refresh each time a toSAX is called |
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. |
void |
restore(SaveParameters save_config)
Restore the repository |
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, getClassNameSuffix, getDocumentGetQuery, isDefault, loadBaseConfiguration, optimize, setIsDefault |
Methods inherited from class fr.gouv.culture.sdx.utils.rdbms.DataSourceComponentBacked |
---|
finalize, getDataSourceComponent, releaseDataSourceComponent, service |
Methods inherited from class fr.gouv.culture.sdx.utils.rdbms.JDBC |
---|
createTable, getTableName, handleUnsupportedTokens |
Methods inherited from class fr.gouv.culture.sdx.utils.AbstractSdxObject |
---|
configureDescription, contextualize, enableLogging, getBaseAttributes, getConfiguration, getContext, getDescription, getEncoding, getId, getLocale, getLog, getServiceManager, getXmlLang, setDescription, setEncoding, setId, setLocale, setUpSdxObject, setUpSdxObject, setXmlLang, toSAX, verifyConfigurationResources |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface fr.gouv.culture.sdx.utils.SdxObject |
---|
getLog |
Methods inherited from interface org.apache.avalon.framework.logger.LogEnabled |
---|
enableLogging |
Methods inherited from interface org.apache.avalon.framework.context.Contextualizable |
---|
contextualize |
Methods inherited from interface org.apache.avalon.framework.service.Serviceable |
---|
service |
Methods inherited from interface fr.gouv.culture.sdx.utils.Identifiable |
---|
getId, setId |
Methods inherited from interface fr.gouv.culture.sdx.utils.Describable |
---|
getDescription, setDescription |
Methods inherited from interface fr.gouv.culture.sdx.utils.Encodable |
---|
getEncoding, setEncoding |
Methods inherited from interface fr.gouv.culture.sdx.utils.Localizable |
---|
getLocale, getXmlLang, setLocale, setXmlLang |
Methods inherited from interface org.apache.excalibur.xml.sax.XMLizable |
---|
toSAX |
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 super.getLog() must be set and then this repository must be configured and initialized.
AbstractSdxObject.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 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 DataSourceComponentBacked
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.
protected java.lang.String getEntriesWithLimitQuery(long offset, long number)
offset
- number
-
protected boolean initToSax()
AbstractSdxObject
initToSax
in class AbstractSdxObject
protected void initVolatileObjectsToSax()
initVolatileObjectsToSax
in class JDBC
public void backup(SaveParameters save_config) throws SDXException
SDXException
Saveable.backup(fr.gouv.culture.sdx.utils.save.SaveParameters)
public void restore(SaveParameters save_config) throws SDXException
SDXException
Saveable.restore(fr.gouv.culture.sdx.utils.save.SaveParameters)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |