org.apache.ws.jaxme.pm.xmldb
Class XmlDbPM

java.lang.Object
  extended by org.apache.ws.jaxme.pm.impl.PMImpl
      extended by org.apache.ws.jaxme.pm.impl.PMIdImpl
          extended by org.apache.ws.jaxme.pm.xmldb.XmlDbPM
All 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.
 java.lang.String getCollection()
          Returns the collection name.
 java.lang.Class getDriverClass()
          Returns the driver class.
 java.lang.String getPassword()
          Returns the password.
 java.lang.String getUser()
          Returns the users name.
protected  org.xmldb.api.base.Collection getXmlDbCollection()
          Returns the database collection by invoking DatabaseManager.getCollection(String).
 java.lang.String getXPathQueryService()
          Returns the name of the XPathQueryService.
 java.lang.String getXPathQueryServiceVersion()
          Returns the version of the XPathQueryService.
 void init(JMManager pManager)
          Initializes the PM.
 void insert(Element pElement)
          Inserts the given document into the database.
 void select(Observer pObserver, java.lang.String pQuery, PMParams pPlaceHolderArgs)
          Reads documents matching the given query.
 void setCollection(java.lang.String pCollection)
          Sets the collection name.
 void setDriverClass(java.lang.Class pDriverClass)
          Sets the driver class.
 void setPassword(java.lang.String pPassword)
          Sets the password.
 void setUser(java.lang.String pUser)
          Sets the users name.
 void setXPathQueryService(java.lang.String pXpathQueryService)
          Sets the name of the XPathQueryService.
 void setXPathQueryServiceVersion(java.lang.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, setGetIdMethodName
 
Methods inherited from class org.apache.ws.jaxme.pm.impl.PMImpl
create, getManager, parseQuery, select, select, select
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlDbPM

public XmlDbPM()
Creates a new instance of XmlDbPM.

Method Detail

init

public void init(JMManager pManager)
          throws JAXBException
Description copied from interface: PM

Initializes the PM. Called from the JAXBContextImpl upon initialization.

Specified by:
init in interface PM
Overrides:
init in class PMIdImpl
Parameters:
pManager - The manager being queried for configuration details.
Throws:
JAXBException

getCollection

public java.lang.String getCollection()
Returns the collection name.


setCollection

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


getDriverClass

public java.lang.Class getDriverClass()
Returns the driver class.


setDriverClass

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


getPassword

public java.lang.String getPassword()
Returns the password.


setPassword

public void setPassword(java.lang.String pPassword)
Sets the password.


getUser

public java.lang.String getUser()
Returns the users name.


setUser

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


getXPathQueryService

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


setXPathQueryService

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


getXPathQueryServiceVersion

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


setXPathQueryServiceVersion

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


getXmlDbCollection

protected org.xmldb.api.base.Collection getXmlDbCollection()
                                                    throws org.xmldb.api.base.XMLDBException,
                                                           java.lang.IllegalAccessException,
                                                           java.lang.InstantiationException
Returns the database collection by invoking DatabaseManager.getCollection(String).

Throws:
org.xmldb.api.base.XMLDBException
java.lang.IllegalAccessException
java.lang.InstantiationException

select

public void select(Observer pObserver,
                   java.lang.String pQuery,
                   PMParams pPlaceHolderArgs)
            throws JAXBException
Description copied from interface: PM

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));
 

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.
Throws:
JAXBException

insert

public void insert(Element pElement)
            throws PMException
Description copied from interface: PM

Inserts the given document into the database.

Throws:
PMException

update

public void update(Element pElement)
            throws PMException
Description copied from interface: PM

Updates the given document in the database.

Throws:
PMException

delete

public void delete(Element pElement)
            throws PMException
Description copied from interface: PM

Deletes the given document from the database.

Throws:
PMException