i3.dragos.core.services.transactions.localmgr
Class LocalTransactionManager

java.lang.Object
  extended by i3.dragos.core.services.transactions.localmgr.LocalTransactionManager
All Implemented Interfaces:
TransactionManager

public class LocalTransactionManager
extends java.lang.Object
implements TransactionManager

A custom TransactionManager implementation. Supports nested transactions as well as transactions distributed across multiple GraphPools.

Author:
Ernest Hammerschmidt <ernest@i3.informatik.rwth-aachen.de>, Thorsten Hermes <thermes@i3.informatik.rwth-aachen.de>

Field Summary
static java.lang.String IMPLEMENTATION_NAME
          This implementation's descriptive name
 
Constructor Summary
LocalTransactionManager(DataSourceURL[] dataSourceURLs)
          Creates a new LocalTransactionManager (required constructor for reflection).
 
Method Summary
 void acquireCommitSemaphore()
          Acquires the commit semaphore for this thread.
 Transaction createTransaction()
          Creates a Transaction object for the specific implementation.
protected  LocalTransaction createTransaction0(DataSource[] ds, LocalTransaction parentTransaction)
          Factory method for transactions.
 Transaction getCurrentTransaction()
          Gets the currently active Transaction, if any.
 java.util.Collection<DataSourceURL> getManagedDataSources()
          Returns a Collection of DataSourceURLs for all GraphPools managed by this TransactionManager.
 void releaseCommitSemaphore()
          Releases the commit semaphore for this thread.
 void removeTransaction()
          Removes a transaction from the map.
 Transaction requestTransaction()
          Gets the currently active Transaction or initializes a new one if none is currently active.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMPLEMENTATION_NAME

public static final java.lang.String IMPLEMENTATION_NAME
This implementation's descriptive name

See Also:
Constant Field Values
Constructor Detail

LocalTransactionManager

public LocalTransactionManager(DataSourceURL[] dataSourceURLs)
                        throws TransactionManagerException
Creates a new LocalTransactionManager (required constructor for reflection).

Parameters:
dataSourceURLs - The URLs of the DataSources to operate on.
Throws:
TransactionManagerException - if the supplied array is empty or contains a null value.
Method Detail

getManagedDataSources

public java.util.Collection<DataSourceURL> getManagedDataSources()
                                                          throws TransactionException
Returns a Collection of DataSourceURLs for all GraphPools managed by this TransactionManager.

Specified by:
getManagedDataSources in interface TransactionManager
Returns:
a Collection of DataSourceURLs for all GraphPools managed by this TransactionManager.
Throws:
TransactionException - if something goes wrong.

createTransaction

public Transaction createTransaction()
                              throws TransactionException
Creates a Transaction object for the specific implementation. If a transaction is already active, this creates either a nested transaction or throws an exception (if nested transactions are not supported).

Specified by:
createTransaction in interface TransactionManager
Returns:
a Transaction instance (never null).
Throws:
TransactionException - if something goes wrong.

getCurrentTransaction

public Transaction getCurrentTransaction()
                                  throws TransactionException
Gets the currently active Transaction, if any.

A transaction is considered the current one if it is not in state Transaction.State.PRECOMMIT, Transaction.State.COMMITTED or Transaction.State.ROLLED_BACK, and has no active nested transactions.

Specified by:
getCurrentTransaction in interface TransactionManager
Returns:
a Transaction instance or null if none is active at the moment.
Throws:
TransactionException - if something goes wrong.

requestTransaction

public Transaction requestTransaction()
                               throws TransactionException
Gets the currently active Transaction or initializes a new one if none is currently active.

This convenience method is a simple combination of TransactionManager.getCurrentTransaction() with an optional TransactionManager.createTransaction().

Specified by:
requestTransaction in interface TransactionManager
Returns:
a Transaction instance (never null).
Throws:
TransactionException - if something goes wrong.

removeTransaction

public void removeTransaction()
Removes a transaction from the map. Called whenever a top-level transaction finishes (commit or rollback).


acquireCommitSemaphore

public void acquireCommitSemaphore()
Acquires the commit semaphore for this thread.


releaseCommitSemaphore

public void releaseCommitSemaphore()
Releases the commit semaphore for this thread.


createTransaction0

protected LocalTransaction createTransaction0(DataSource[] ds,
                                              LocalTransaction parentTransaction)
                                       throws TransactionException
Factory method for transactions.

Parameters:
ds - DataSource to work with.
parentTransaction - parent transaction if any.
Returns:
the new transaction.
Throws:
TransactionException - if the DataSourceTransaction could not be created.


Copyright © 2002-2008 RWTH Aachen, Department of Computer Science 3 (Software Engineering). All Rights Reserved.