org.exist.xmldb
Class DatabaseImpl

java.lang.Object
  extended byorg.exist.xmldb.DatabaseImpl
All Implemented Interfaces:
Configurable, Database

public class DatabaseImpl
extends java.lang.Object
implements Database

The XMLDB driver class for eXist. This driver manages two different internal implementations. The first communicates with a remote database using the XMLRPC protocol. The second has direct access to an embedded database instance running in the same virtual machine. The driver chooses an implementation depending on the XML:DB URI passed to getCollection(). When running in embedded mode, the driver can create a new database instance if none is available yet. It will do so if the property "create-database" is set to "true" or if there is a system property "exist.initdb" with value "true". You may optionally provide the location of an alternate configuration file through the "configuration" property. The driver is also able to address different database instances - which may have been installed at different places.

Author:
Wolfgang Meier

Field Summary
static java.lang.String CONF_XML
          Default config filename to configure an Instance
 
Constructor Summary
DatabaseImpl()
           
 
Method Summary
 boolean acceptsURI(java.lang.String uri)
          acceptsURI determines whether this Database implementation can handle the URI.
 boolean acceptsURI(XmldbURI xmldbURI)
           
 Collection getCollection(java.lang.String uri, java.lang.String user, java.lang.String password)
          Retrieves a Collection instance based on the URI provided in the uri parameter.
 Collection getCollection(XmldbURI xmldbURI, java.lang.String user, java.lang.String password)
           
 java.lang.String getConformanceLevel()
          Returns the XML:DB API Conformance level for the implementation.
 java.lang.String getName()
          Returns the name associated with the Database instance.
 java.lang.String[] getNames()
          Returns an array of names associated with the Database instance.
 java.lang.String getProperty(java.lang.String property)
          Returns the value of the property identified by name.
static Collection readCollection(java.lang.String c, org.apache.xmlrpc.XmlRpcClient rpcClient)
           
 void setDatabaseShutdownListener(ShutdownListener listener)
          Register a ShutdownListener for the current database instance.
 void setProperty(java.lang.String property, java.lang.String value)
          Sets the property name to have the value provided in value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONF_XML

public static final java.lang.String CONF_XML
Default config filename to configure an Instance

See Also:
Constant Field Values
Constructor Detail

DatabaseImpl

public DatabaseImpl()
Method Detail

acceptsURI

public boolean acceptsURI(java.lang.String uri)
                   throws XMLDBException
Description copied from interface: Database
acceptsURI determines whether this Database implementation can handle the URI. It should return true if the Database instance knows how to handle the URI and false otherwise.

Specified by:
acceptsURI in interface Database
Parameters:
uri - the URI to check for.
Returns:
true if the URI can be handled, false otherwise.
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrroCodes.INVALID_URI If the URI is not in a valid format.

acceptsURI

public boolean acceptsURI(XmldbURI xmldbURI)
                   throws XMLDBException
Throws:
XMLDBException

getCollection

public Collection getCollection(java.lang.String uri,
                                java.lang.String user,
                                java.lang.String password)
                         throws XMLDBException
Description copied from interface: Database
Retrieves a Collection instance based on the URI provided in the uri parameter. The format of the URI is defined in the documentation for DatabaseManager.getCollection().

Authentication is handled via username and password however it is not required that the database support authentication. Databases that do not support authentication MUST ignore the username and password if those provided are not null.

Specified by:
getCollection in interface Database
Parameters:
uri - the URI to use to locate the collection.
password - The password to use for authentication to the database or null if the database does not support authentication.
Returns:
A Collection instance for the requested collection or null if the collection could not be found.
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.
ErrroCodes.INVALID_URI If the URI is not in a valid format.
ErrroCodes.PERMISSION_DENIED If the username and password were not accepted by the database.

getCollection

public Collection getCollection(XmldbURI xmldbURI,
                                java.lang.String user,
                                java.lang.String password)
                         throws XMLDBException
Throws:
XMLDBException

readCollection

public static Collection readCollection(java.lang.String c,
                                        org.apache.xmlrpc.XmlRpcClient rpcClient)
                                 throws XMLDBException
Throws:
XMLDBException

setDatabaseShutdownListener

public void setDatabaseShutdownListener(ShutdownListener listener)
                                 throws XMLDBException
Register a ShutdownListener for the current database instance. The ShutdownListener is called after the database has shut down. You have to register a listener before any calls to getCollection().

Parameters:
listener -
Throws:
XMLDBException

getConformanceLevel

public java.lang.String getConformanceLevel()
                                     throws XMLDBException
Description copied from interface: Database
Returns the XML:DB API Conformance level for the implementation. This can be used by client programs to determine what functionality is available to them.

Specified by:
getConformanceLevel in interface Database
Returns:
the XML:DB API conformance level for this implementation.
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.

getName

public java.lang.String getName()
                         throws XMLDBException
Description copied from interface: Database
Returns the name associated with the Database instance.

Specified by:
getName in interface Database
Returns:
the name of the object.
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.

getNames

public java.lang.String[] getNames()
                            throws XMLDBException
Description copied from interface: Database
Returns an array of names associated with the Database instance.

Specified by:
getNames in interface Database
Returns:
the array of name of the object.
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.

getProperty

public java.lang.String getProperty(java.lang.String property)
                             throws XMLDBException
Description copied from interface: Configurable
Returns the value of the property identified by name.

Specified by:
getProperty in interface Configurable
Parameters:
property - the name of the property to retrieve.
Returns:
the property value or null if no property exists.
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.

setProperty

public void setProperty(java.lang.String property,
                        java.lang.String value)
                 throws XMLDBException
Description copied from interface: Configurable
Sets the property name to have the value provided in value.

Specified by:
setProperty in interface Configurable
Parameters:
property - the name of the property to set.
value - the value to set for the property.
Throws:
XMLDBException - with expected error codes.
ErrorCodes.VENDOR_ERROR for any vendor specific errors that occur.


Copyright (C) Wolfgang Meier. All rights reserved.