org.xquark.xml.xdbc
Class DefaultReadOnlyXMLConnection

java.lang.Object
  |
  +--org.xquark.xml.xdbc.DefaultReadOnlyXMLConnection
All Implemented Interfaces:
XMLConnection

public abstract class DefaultReadOnlyXMLConnection
extends java.lang.Object
implements XMLConnection

A default implementation of XMLConnection for read-only connections


Field Summary
 
Fields inherited from interface org.xquark.xml.xdbc.XMLConnection
MEDIATOR_STRING_TYPE, TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE, XPATH_STRING_TYPE, XQUERY_STRING_TYPE
 
Constructor Summary
DefaultReadOnlyXMLConnection()
          Creates a new instance of DefaultReadOnlyXMLConnection
 
Method Summary
 void commit()
          Makes all changes made since the previous commit/rollback permanent and releases any data source locks currently held by the connection.
 XMLCollection createCollection(java.lang.String name, java.lang.String description, Configurable config)
          To create a new XML collection.
 Configurable createCollectionConfig()
          To create a new XML Collection configuration for set features and properties before create a XML Collection.
 int deleteAllCollections()
          To delete all XML collections of this connection.
 void deleteCollection(java.lang.String name)
          To delete a XML collection by its name.
 boolean getAutoCommit()
          To know the current auto-commit state.
 XMLCollection getCollection(java.lang.String name)
          To retrieve a XMLcollection by its name.
 short getTransactionIsolation()
          Gets this connection's current transaction isolation level.
 boolean isReadOnly()
          To know the read/write mode of the current connection.
 void renameCollection(java.lang.String oldname, java.lang.String newname)
          To rename an XML collection by its name.
 void rollback()
          Drops all changes made since the previous commit/rollback and releases any data source locks currently held by this connection.
 void setAutoCommit(boolean autoCommitMode)
          Sets this connection's auto-commit mode.
 void setReadOnly(boolean readOnlyMode)
          To change the read/write mode of the connection.
 void setTransactionIsolation(short level)
          Attempts to change the transaction isolation level to the one given.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.xquark.xml.xdbc.XMLConnection
close, createStatement, createStatement, getMetaData, getMetaData, getURL, getUserName, isClosed, prepareStatement, prepareStatement
 

Constructor Detail

DefaultReadOnlyXMLConnection

public DefaultReadOnlyXMLConnection()
Creates a new instance of DefaultReadOnlyXMLConnection

Method Detail

commit

public void commit()
            throws XMLDBCException,
                   XMLDBCNotSupportedException
Makes all changes made since the previous commit/rollback permanent and releases any data source locks currently held by the connection. This method has no effect when auto-commit mode has been enabled.

Specified by:
commit in interface XMLConnection
Throws:
XMLDBCException - if a data source access error occurs.
XMLDBCNotSupportedException - if the data source does not support transactions

createCollection

public XMLCollection createCollection(java.lang.String name,
                                      java.lang.String description,
                                      Configurable config)
                               throws XMLDBCException,
                                      XMLDBCNotSupportedException
To create a new XML collection. Each XML collections can be configured.

Specified by:
createCollection in interface XMLConnection
Parameters:
name - the unique name of the new XML collection.
description - the description of the new XML collection (optional).
config - a XML collection configuration. If null, the XML collection will be created with default configuration.
Returns:
an instance of XML collection.
Throws:
XMLDBCException - if a data source access error occurs or if the XML collection name already exists.
XMLDBCNotSupportedException - if the data source does not support this operation (typically, when the data source is read-only)

createCollectionConfig

public Configurable createCollectionConfig()
                                    throws XMLDBCException,
                                           XMLDBCNotSupportedException
To create a new XML Collection configuration for set features and properties before create a XML Collection.

Specified by:
createCollectionConfig in interface XMLConnection
Returns:
a XML Collection config.
Throws:
XMLDBCException - if a data source access error occurs.
XMLDBCNotSupportedException - if the data source does not support this operation (typically, when the data source is read-only)

deleteAllCollections

public int deleteAllCollections()
                         throws XMLDBCException,
                                XMLDBCNotSupportedException
To delete all XML collections of this connection.

Specified by:
deleteAllCollections in interface XMLConnection
Returns:
the number of XML collections deleted.
Throws:
XMLDBCException - if a data source access error occurs.
XMLDBCNotSupportedException - if the data source does not support this operation (typically, when the data source is read-only)

deleteCollection

public void deleteCollection(java.lang.String name)
                      throws XMLDBCException,
                             XMLDBCNotSupportedException
To delete a XML collection by its name.

Specified by:
deleteCollection in interface XMLConnection
Parameters:
name - the unique name of an existing XML collection.
Throws:
XMLDBCException - if a data source access error occurs or if the XML collection does not exist.
XMLDBCNotSupportedException - if the data source does not support this operation (typically, when the data source is read-only)

getAutoCommit

public boolean getAutoCommit()
                      throws XMLDBCException,
                             XMLDBCNotSupportedException
To know the current auto-commit state.

Specified by:
getAutoCommit in interface XMLConnection
Returns:
true if the current connection is in auto-commit mode, else false.
Throws:
XMLDBCException - if a data source access error occurs.
XMLDBCNotSupportedException - if the data source does not support transactions

getTransactionIsolation

public short getTransactionIsolation()
                              throws XMLDBCException,
                                     XMLDBCNotSupportedException
Gets this connection's current transaction isolation level.

Specified by:
getTransactionIsolation in interface XMLConnection
Returns:
the current TRANSACTION_* mode value (see fields summary).
Throws:
XMLDBCException - if a data source access error occurs.
XMLDBCNotSupportedException - if the data source does not support transactions

getCollection

public XMLCollection getCollection(java.lang.String name)
                            throws XMLDBCException,
                                   XMLDBCNotSupportedException
To retrieve a XMLcollection by its name.

Specified by:
getCollection in interface XMLConnection
Parameters:
name - a name of XML collection.
Returns:
the XML collection that has the specified name or 'null' if there is no XML collection with this name.
Throws:
XMLDBCException - if a data source access error occurs.
XMLDBCNotSupportedException - if the data source does not support this operation (typically, when the data source is read-only)

isReadOnly

public boolean isReadOnly()
                   throws XMLDBCException
To know the read/write mode of the current connection.

Specified by:
isReadOnly in interface XMLConnection
Returns:
true if connection is read-only, else false.
Throws:
XMLDBCException - if a data source access error occurs.

renameCollection

public void renameCollection(java.lang.String oldname,
                             java.lang.String newname)
                      throws XMLDBCException,
                             XMLDBCNotSupportedException
To rename an XML collection by its name.

Specified by:
renameCollection in interface XMLConnection
Parameters:
oldname - the unique name of an existing XML collection.
newname - the new unique name of an existing XML collection.
Throws:
XMLDBCException - if a data source access error errors, if the collection does not exist, or if the new name is not unique.
XMLDBCNotSupportedException - if the data source does not support this operation (typically, when the data source is read-only)

rollback

public void rollback()
              throws XMLDBCException,
                     XMLDBCNotSupportedException
Drops all changes made since the previous commit/rollback and releases any data source locks currently held by this connection. This method should be used only when auto-commit has been disabled.

Specified by:
rollback in interface XMLConnection
Throws:
XMLDBCException - if a data source access error occurs.
XMLDBCNotSupportedException - if the data source does not support transactions

setAutoCommit

public void setAutoCommit(boolean autoCommitMode)
                   throws XMLDBCException,
                          XMLDBCNotSupportedException
Sets this connection's auto-commit mode. If the parameter is true, a commit will be done after each statement execution, else otherwise a commit will have to be made explicitly by calling the commit method.

Specified by:
setAutoCommit in interface XMLConnection
Parameters:
autoCommitMode - if true, the connection will pass in auto-commit mode, else in manual commit mode.
Throws:
XMLDBCException - if a data source access error occurs.
XMLDBCNotSupportedException - if the data source does not support transactions

setReadOnly

public void setReadOnly(boolean readOnlyMode)
                 throws XMLDBCException,
                        XMLDBCNotSupportedException
To change the read/write mode of the connection. Some data source could make optimisations if the connection is in read-only mode.

Specified by:
setReadOnly in interface XMLConnection
Parameters:
readOnlyMode - if true, the connection will pass in read-only mode, else in read/write mode.
Throws:
XMLDBCException - if a data source access error occurs.
XMLDBCNotSupportedException - if the data source is read-only and the parameter is false.

setTransactionIsolation

public void setTransactionIsolation(short level)
                             throws XMLDBCException,
                                    XMLDBCNotSupportedException
Attempts to change the transaction isolation level to the one given. The constants defined in the interface Connection are the possible transaction isolation levels. This method cannot be called while in the middle of a transaction.

Specified by:
setTransactionIsolation in interface XMLConnection
Parameters:
level - one of the TRANSACTION_* (see field summary) isolation values with the exception of TRANSACTION_NONE; some data sources may not support other values.
Throws:
XMLDBCException - if a data source access error occurs.
XMLDBCNotSupportedException - if the data source does not support transactions


Copyright © 2004 Université de Versailles Saint-Quentin, XQuark Group. All rights reserved.