Package org.xmldb.api
Class DatabaseManager
java.lang.Object
org.xmldb.api.DatabaseManager
DatabaseManager
is the entry point for the API and enables you to get the
initial Collection
references necessary to do anything useful with the API.
DatabaseManager
is intended to be
provided as a concrete implementation in a particular programming
language. Individual language mappings should define the exact syntax and
semantics of its use.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
deregisterDatabase
(Database database) Deregisters aDatabase
implementation from theDatabaseManager
.static Collection
getCollection
(String uri) Retrieves aCollection
instance from the database for the given URI.static Collection
getCollection
(String uri, String username, String password) Retrieves aCollection
instance from the database for the given URI.static String
Returns the Core Level conformance value for the provided URI.static Database[]
Returns a list of all availableDatabase
implementations that have been registered with thisDatabaseManager
.static String
getProperty
(String name) Retrieves a property that has been set for theDatabaseManager
.static void
registerDatabase
(Database database) Registers a newDatabase
implementation with theDatabaseManager
.static void
setProperty
(String name, String value) Sets a property for theDatabaseManager
.
-
Constructor Details
-
DatabaseManager
public DatabaseManager()
-
-
Method Details
-
getDatabases
Returns a list of all availableDatabase
implementations that have been registered with thisDatabaseManager
.- Returns:
- An array of
Database
instances. One for eachDatabase
registered with theDatabaseManager
. If noDatabase
instances exist then an empty array is returned.
-
registerDatabase
Registers a newDatabase
implementation with theDatabaseManager
.- Parameters:
database
- The database instance to register.- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
ErrorCodes.INVALID_DATABASE
if the providedDatabase
instance is invalid.
-
deregisterDatabase
Deregisters aDatabase
implementation from theDatabaseManager
. Once aDatabase
has been deregistered it can no longer be used to handle requests.- Parameters:
database
- TheDatabase
instance to deregister.- Throws:
XMLDBException
- with expected error codes.
ErrorCodes.VENDOR_ERROR
for any vendor specific errors that occur.
-
getCollection
Retrieves aCollection
instance from the database for the given URI. The format of the majority of the URI is database implementation specific however the uri must begin with characters xmldb: and be followed by the name of the database instance as returned byDatabase.getName()
and a colon character. An example would be for the database named "vendordb" the URI handed to getCollection would look something like the following.xmldb:vendordb://host:port/path/to/collection
. The xmldb: prefix will be removed from the URI prior to handing the URI to theDatabase
instance for handling. This method is called when no authentication is necessary for the database.- Parameters:
uri
- The database specific URI to use to locate the collection.- 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.NO_SUCH_DATABASE
If aDatabase
instance could not be found to handle the provided URI.
-
getCollection
public static Collection getCollection(String uri, String username, String password) throws XMLDBException Retrieves aCollection
instance from the database for the given URI. The format of the majority of the URI is database implementation specific however the uri must begin with characters xmldb: and be followed by the name of the database instance as returned byDatabase.getName()
and a colon character. An example would be for the database named "vendordb" the URI handed to getCollection would look something like the following.xmldb:vendordb://host:port/path/to/collection
. The xmldb: prefix will be removed from the URI prior to handing the URI to theDatabase
instance for handling.- Parameters:
uri
- The database specific URI to use to locate the collection.username
- The username to use for authentication to the database or null if the database does not support authentication.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.NO_SUCH_DATABASE
If aDatabase
instance could not be found to handle the provided URI.ErrroCodes.PERMISSION_DENIED
If theusername
andpassword
were not accepted by the database.
-
getConformanceLevel
Returns the Core Level conformance value for the provided URI. The current API defines valid resuls of "0" or "1" as defined in the XML:DB API specification.- Parameters:
uri
- The database specific URI to use to locate the collection.- Returns:
- The XML:DB Core Level conformance for the uri.
- 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.NO_SUCH_DATABASE
If aDatabase
instance could not be found to handle the provided URI.
-
getProperty
Retrieves a property that has been set for theDatabaseManager
.- Parameters:
name
- The property name- Returns:
- The property value
-
setProperty
Sets a property for theDatabaseManager
.- Parameters:
name
- The property namevalue
- The value to set.
-