org.apache.ws.jaxme.pm.xmldb

Class XmlDbPM

Implemented Interfaces:
PM

public class XmlDbPM
extends PMIdImpl

This is a persistence manager for the XML::DB interface. In other words, using this persistence manager you may read documents from a database via the XML::DB API or write them into the database using the same API.
This persistence manager is generic: The same manager works fine for any JAXB element.

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.ws.jaxme.pm.impl.PMImpl

PMImpl.ListObserver

Constructor Summary

XmlDbPM()
Creates a new instance of XmlDbPM.

Method Summary

void
delete(Element pElement)
Deletes the given document from the database.
String
getCollection()
Returns the collection name.
Class
getDriverClass()
Returns the driver class.
String
getPassword()
Returns the password.
String
getUser()
Returns the users name.
String
getXPathQueryService()
Returns the name of the XPathQueryService.
String
getXPathQueryServiceVersion()
Returns the version of the XPathQueryService.
protected Collection
getXmlDbCollection()
Returns the database collection by invoking DatabaseManager.getCollection(String).
void
init(JMManager pManager)
Initializes the PM.
void
insert(Element pElement)
Inserts the given document into the database.
void
select(Observer pObserver, String pQuery, PMParams pPlaceHolderArgs)
Reads documents matching the given query.
void
setCollection(String pCollection)
Sets the collection name.
void
setDriverClass(Class pDriverClass)
Sets the driver class.
void
setPassword(String pPassword)
Sets the password.
void
setUser(String pUser)
Sets the users name.
void
setXPathQueryService(String pXpathQueryService)
Sets the name of the XPathQueryService.
void
setXPathQueryServiceVersion(String pXpathQueryServiceVersion)
Sets the version of the XPathQueryService.
void
update(Element pElement)
Updates the given document in the database.

Methods inherited from class org.apache.ws.jaxme.pm.impl.PMIdImpl

getGetIdMethodName, getId, init, setGetIdMethodName

Methods inherited from class org.apache.ws.jaxme.pm.impl.PMImpl

create, getManager, init, parseQuery, select, select, select

Constructor Details

XmlDbPM

public XmlDbPM()
Creates a new instance of XmlDbPM.

Method Details

delete

public void delete(Element pElement)
            throws PMException
Deletes the given document from the database.
Specified by:
delete in interface PM

getCollection

public String getCollection()
Returns the collection name.

getDriverClass

public Class getDriverClass()
Returns the driver class.

getPassword

public String getPassword()
Returns the password.

getUser

public String getUser()
Returns the users name.

getXPathQueryService

public String getXPathQueryService()
Returns the name of the XPathQueryService. Defaults to "XPathQueryService".

getXPathQueryServiceVersion

public String getXPathQueryServiceVersion()
Returns the version of the XPathQueryService. Defaults to "1.0".

getXmlDbCollection

protected Collection getXmlDbCollection()
            throws XMLDBException,
                   IllegalAccessException,
                   InstantiationException
Returns the database collection by invoking DatabaseManager.getCollection(String).

init

public void init(JMManager pManager)
            throws JAXBException
Initializes the PM. Called from the JAXBContextImpl upon initialization.
Specified by:
init in interface PM
Overrides:
init in interface PMIdImpl
Parameters:
pManager - The manager being queried for configuration details.

insert

public void insert(Element pElement)
            throws PMException
Inserts the given document into the database.
Specified by:
insert in interface PM

select

public void select(Observer pObserver,
                   String pQuery,
                   PMParams pPlaceHolderArgs)
            throws JAXBException
Reads documents matching the given query. For any document matching, the Observer's notify method is executed with the matching document as an argument.

The query may contain placeholders. If it does, you have to supply an instance of PMParams with the placeholder values. Example:

   manager.select("Name = ? and Id = ?",
                  new PMParams().addString("Someone").addInt(4));
 
Specified by:
select in interface PM
Parameters:
pObserver - This Observer is notified for any matching document. The document is added as an argument.
pQuery - The query to perform. May contain placeholders.
pPlaceHolderArgs - An array of objects or null, if the query doesn't contain any placeholders.

setCollection

public void setCollection(String pCollection)
Sets the collection name.

setDriverClass

public void setDriverClass(Class pDriverClass)
Sets the driver class.

setPassword

public void setPassword(String pPassword)
Sets the password.

setUser

public void setUser(String pUser)
Sets the users name.

setXPathQueryService

public void setXPathQueryService(String pXpathQueryService)
Sets the name of the XPathQueryService. Defaults to "XPathQueryService".

setXPathQueryServiceVersion

public void setXPathQueryServiceVersion(String pXpathQueryServiceVersion)
Sets the version of the XPathQueryService. Defaults to "1.0".

update

public void update(Element pElement)
            throws PMException
Updates the given document in the database.
Specified by:
update in interface PM