org.oreodata.jdbcimpl
Class JDBCTransactionalDataSource

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--org.oreodata.AbstractDataSource
                          |
                          +--org.oreodata.jdbcimpl.JDBCBackedRecordSet
                                |
                                +--org.oreodata.jdbcimpl.JDBCTransactionalDataSource
All Implemented Interfaces:
DataListener, java.util.EventListener, OreoDataSource, java.rmi.Remote, java.io.Serializable, TransactionalDataSource

public class JDBCTransactionalDataSource
extends JDBCBackedRecordSet
implements TransactionalDataSource

An oreo transactional data source that wraps a JDBC/SQL database that supports transactions. The following parameters can be set in the XML configuration file:
Parameter Description Default
MAX_TRANSACTION_TIMEOUT how long a transaction can be left idle (in seconds) before it is considered "stale" 3600 seconds (1 hour)
NATIVE_TRANSACTION_SUPPORT Whether the underlying JDBC datasource natively supports transactions. If this is set to "N" then we "fake it". (Note that this is still experimental.) "Y"

All of the initialization parameters defined for JDBCBackedRecordSet apply to this subclass.

See Also:
JDBCBackedRecordSet, Serialized Form

Field Summary
 
Fields inherited from class org.oreodata.jdbcimpl.JDBCBackedRecordSet
checkConcurrentUpdate, defaultRecordType, doubleQuoteLiteral, driverClassName, jdbcURL, maxCacheSize, maxConnections, minConnections, password, pool, userID
 
Fields inherited from class org.oreodata.AbstractDataSource
defaultCharEncoding, lastLogRotation, transactionCount
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
JDBCTransactionalDataSource()
           
 
Method Summary
 void abortTransaction(java.lang.String txnID)
          cancel the transaction associated with the ID
 void addDataListener(DataListener dl)
          Add a listener that gets notified if ever a record is inserted, updated or deleted.
 void commit(java.lang.String txnID)
          Commit the transaction that is identified by this txnID
 void delete(java.lang.String type, java.lang.Object key, java.lang.String txnID)
          delete the Record of the given type and primary key taking into account the transaction which this is part of.
 Record get(java.lang.String type, java.lang.Object key, java.lang.String txnID)
           
 Transaction getTransaction(java.lang.String txnID)
           
 void init(java.util.Properties props)
          A method that initializes a DataSource with a set of initialization properties.
 void insert(Record rec, java.lang.String txnID)
          update the Record taking into account the transaction which this is part of.
 java.lang.String newTransaction()
           
 void removeDataListener(DataListener dl)
          Remove a listener that gets notified if ever a record is inserted, updated or deleted.
protected  void removeTransaction(java.lang.String txnID)
           
 void rollback(java.lang.String txnID)
          Roll back the transaction
 java.util.List select(RecordFilter filter, java.lang.String txnID)
           
 void update(Record oldRec, Record newRec, java.lang.String txnID)
          update the Record taking into account the transaction which this is part of.
 
Methods inherited from class org.oreodata.jdbcimpl.JDBCBackedRecordSet
close, delete, delete, get, getConnection, insert, keys, select, uniqueKey, update, wipeCache
 
Methods inherited from class org.oreodata.AbstractDataSource
fireDataEvent, fireEvents, freeze, freeze, get, getName, handleEvent, keys, lookup, markStale, normalizeKey, reload, reload, select, setFireEvents, setUseXML, useXML, writeElement, writeSnapshot
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.oreodata.OreoDataSource
close, delete, delete, get, get, getName, insert, keys, keys, lookup, reload, reload, select, select, update, wipeCache, writeElement, writeSnapshot
 
Methods inherited from interface org.oreodata.DataListener
handleEvent
 

Constructor Detail

JDBCTransactionalDataSource

public JDBCTransactionalDataSource()
                            throws java.io.IOException
Method Detail

init

public void init(java.util.Properties props)
          throws java.io.IOException
Description copied from interface: OreoDataSource
A method that initializes a DataSource with a set of initialization properties. This is called internally within Oreo and should not be called by application code. As an implementor, you should make sure that this method is only called once, for example, throw a RuntimeException if an attempt is made to call this on a DataSource a second time.

Specified by:
init in interface OreoDataSource
Overrides:
init in class JDBCBackedRecordSet
java.io.IOException

update

public void update(Record oldRec,
                   Record newRec,
                   java.lang.String txnID)
            throws java.io.IOException
Description copied from interface: TransactionalDataSource
update the Record taking into account the transaction which this is part of.

Specified by:
update in interface TransactionalDataSource
java.io.IOException

get

public Record get(java.lang.String type,
                  java.lang.Object key,
                  java.lang.String txnID)
           throws java.io.IOException
Specified by:
get in interface TransactionalDataSource
Returns:
the Record of the given type and primary key taking into account the transaction which this is part of.
java.io.IOException

rollback

public void rollback(java.lang.String txnID)
              throws java.io.IOException
Description copied from interface: TransactionalDataSource
Roll back the transaction

Specified by:
rollback in interface TransactionalDataSource
java.io.IOException

commit

public void commit(java.lang.String txnID)
            throws java.io.IOException
Description copied from interface: TransactionalDataSource
Commit the transaction that is identified by this txnID

Specified by:
commit in interface TransactionalDataSource
java.io.IOException

insert

public void insert(Record rec,
                   java.lang.String txnID)
            throws java.io.IOException
Description copied from interface: TransactionalDataSource
update the Record taking into account the transaction which this is part of.

Specified by:
insert in interface TransactionalDataSource
java.io.IOException

delete

public void delete(java.lang.String type,
                   java.lang.Object key,
                   java.lang.String txnID)
            throws java.io.IOException
Description copied from interface: TransactionalDataSource
delete the Record of the given type and primary key taking into account the transaction which this is part of.

Specified by:
delete in interface TransactionalDataSource
java.io.IOException

newTransaction

public java.lang.String newTransaction()
                                throws java.io.IOException
Specified by:
newTransaction in interface TransactionalDataSource
Returns:
a unique ID for a new transaction.
java.io.IOException

abortTransaction

public void abortTransaction(java.lang.String txnID)
                      throws java.io.IOException
Description copied from interface: TransactionalDataSource
cancel the transaction associated with the ID

Specified by:
abortTransaction in interface TransactionalDataSource
java.io.IOException

removeTransaction

protected void removeTransaction(java.lang.String txnID)
                          throws java.io.IOException
java.io.IOException

select

public java.util.List select(RecordFilter filter,
                             java.lang.String txnID)
                      throws java.io.IOException
Specified by:
select in interface TransactionalDataSource
Returns:
a List of records that meet the criterion encapsulated by the filter arg, taking into account the transaction which this is part of.
java.io.IOException

getTransaction

public Transaction getTransaction(java.lang.String txnID)
                           throws java.io.IOException
Specified by:
getTransaction in interface TransactionalDataSource
Returns:
the actual org.oreodata.transaction.Transaction object associated with this transaction ID.
java.io.IOException

addDataListener

public void addDataListener(DataListener dl)
Description copied from interface: OreoDataSource
Add a listener that gets notified if ever a record is inserted, updated or deleted.

Specified by:
addDataListener in interface OreoDataSource
Overrides:
addDataListener in class AbstractDataSource
Parameters:
dl - the listener

removeDataListener

public void removeDataListener(DataListener dl)
Description copied from interface: OreoDataSource
Remove a listener that gets notified if ever a record is inserted, updated or deleted.

Specified by:
removeDataListener in interface OreoDataSource
Overrides:
removeDataListener in class AbstractDataSource
Parameters:
dl - the listener