|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xenonsoft.bridgetown.aop.transaction.support.DataSourceResourceController
An implementation of a JDBC resource controller for local transaction support only.
This resource controller does NOT implement global
transaction suspension or resumption. If you want to retrieve
XA data sources from application server JNDI provider and associate
them with a platform transaction manager you should look at
JNDIDataSourceResourceController
instead.
This resource controller does not implement the suspension or
resumption of resources. Because the resource being controlled
are local JDBC connection, then this resource controller will
make call
Connection.commit() or rollback
Connection.rollback() or change
the auto commit mode
Connection.setAutoCommit(boolean)
on JDBC connections. Therefore do not use this resource
controller with JTA transactions!
Moreover, this resource controller saves the state of the auto commit mode and the transaction isolation level when acquiring the JDBC connection. During the release of the JDBC connection these saved states are restored.
The data source is acquired on the call to
openResource(ITransactionContext).
This method attempts to open the JDBC connection from the
newly derived data source.
The acquired JDBC connection, again, is closed on a call to
closeResource(ITransactionContext)
It is possible to supply a ready connection to the resource
controller setConnection(Connection)
before the transaction service manager enlists the
resource controller in a transaction
ITransactionContext.enlistResource(String, IResourceController).
In which case the class just uses it directly.
It remembers not to close the connection, because it did
no acquire it. The owner has the responsibility.
The connection can be retrieved by calling the standard accessor
getResourceConnection()
or alternatively by getConnection(). The former method
is call is used by an AOP transaction method interceptor to
inject the resource into the advised target bean.
| Field Summary | |
protected boolean |
closeOnExit
Close on exit |
protected java.sql.Connection |
connection
JDBC connection |
protected javax.sql.DataSource |
dataSource
JDBC data source |
protected TransactionIsolationEnum |
requestedIsolationLevel
Requested isolation level |
protected int |
requestedTransactionTimeout
Requested transaction timeout |
protected boolean |
saveAutoCommit
Saved auto commit mode |
protected int |
saveIsolationLevel
Saved isolation level |
| Constructor Summary | |
DataSourceResourceController()
Default constructor |
|
DataSourceResourceController(java.sql.Connection connection)
Standard constructor |
|
DataSourceResourceController(javax.sql.DataSource dataSource)
Standard constructor |
|
DataSourceResourceController(javax.sql.DataSource dataSource,
java.sql.Connection connection)
Standard constructor |
|
| Method Summary | |
void |
closeResource(ITransactionContext tx)
Implements / overrides closeResource |
void |
commitResource(ITransactionContext tx)
Implements / overrides commitResource |
java.sql.Connection |
getConnection()
Gets the connection |
javax.sql.DataSource |
getDataSource()
Gets the JDBC dataSource |
TransactionIsolationEnum |
getRequestedIsolationLevel()
Gets the requestedIsolationLevel |
int |
getRequestedTransactionTimeout()
Gets the requestedTransactionTimeout |
java.lang.Object |
getResourceConnection()
Retrieves the connection resource that binds to the application to the transactional resource. |
boolean |
isCloseOnExit()
Gets the closeOnExit |
boolean |
isResourceOpen(ITransactionContext tx)
Implements / overrides isResourceOpen |
void |
openResource(ITransactionContext tx)
Implements / overrides openResource |
boolean |
prepareToCommit(ITransactionContext tx)
Implements / overrides prepareToCommit. |
void |
resumeResource(ITransactionContext tx)
Implements / overrides resumeResource |
void |
rollbackResource(ITransactionContext tx)
Implements / overrides rollbackResource |
void |
setCloseOnExit(boolean closeOnExit)
Sets the closeOnExit |
void |
setConnection(java.sql.Connection connection)
Sets the connection |
void |
setDataSource(javax.sql.DataSource dataSource)
Sets the JDBC dataSource |
void |
setRequestedIsolationLevel(TransactionIsolationEnum requestedIsolationLevel)
Sets the requestedIsolationLevel |
void |
setRequestedTransactionTimeout(int requestedTransactionTimeout)
Sets the requestedTransactionTimeout |
void |
suspendResource(ITransactionContext tx)
Implements / overrides suspendResource |
java.lang.String |
toString()
Returns a human readable string. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected javax.sql.DataSource dataSource
protected java.sql.Connection connection
protected boolean closeOnExit
protected boolean saveAutoCommit
protected int saveIsolationLevel
protected TransactionIsolationEnum requestedIsolationLevel
protected int requestedTransactionTimeout
| Constructor Detail |
public DataSourceResourceController()
public DataSourceResourceController(javax.sql.DataSource dataSource)
dataSource - the JDBC data sourcepublic DataSourceResourceController(java.sql.Connection connection)
connection - a supplied connection
public DataSourceResourceController(javax.sql.DataSource dataSource,
java.sql.Connection connection)
dataSource - the JDBC data sourceconnection - the supplied connection| Method Detail |
public java.lang.String toString()
Object.toString()public javax.sql.DataSource getDataSource()
public void setDataSource(javax.sql.DataSource dataSource)
dataSource - the new value for dataSourcepublic boolean isCloseOnExit()
public void setCloseOnExit(boolean closeOnExit)
closeOnExit - the new value for closeOnExitpublic java.sql.Connection getConnection()
public void setConnection(java.sql.Connection connection)
connection - the new value for connectionpublic TransactionIsolationEnum getRequestedIsolationLevel()
public void setRequestedIsolationLevel(TransactionIsolationEnum requestedIsolationLevel)
setRequestedIsolationLevel in interface IResourceControllerrequestedIsolationLevel - The requestedIsolationLevel to set.public int getRequestedTransactionTimeout()
public void setRequestedTransactionTimeout(int requestedTransactionTimeout)
setRequestedTransactionTimeout in interface IResourceControllerrequestedTransactionTimeout - The requestedTransactionTimeout to set.public java.lang.Object getResourceConnection()
For instance, for a JDBC resource controller, this method
would return the Connection.
getResourceConnection in interface IResourceControllerpublic boolean isResourceOpen(ITransactionContext tx)
isResourceOpen in interface IResourceControllertx -
IResourceController.isResourceOpen(com.xenonsoft.bridgetown.aop.transaction.ITransactionContext)public void openResource(ITransactionContext tx)
openResource in interface IResourceControllertx - the transaction contextIResourceController.openResource(com.xenonsoft.bridgetown.aop.transaction.ITransactionContext)public void suspendResource(ITransactionContext tx)
suspendResource in interface IResourceControllertx - the transaction contextIResourceController.suspendResource(com.xenonsoft.bridgetown.aop.transaction.ITransactionContext)public void resumeResource(ITransactionContext tx)
resumeResource in interface IResourceControllertx - the transaction contextIResourceController.resumeResource(com.xenonsoft.bridgetown.aop.transaction.ITransactionContext)public boolean prepareToCommit(ITransactionContext tx)
With local transaction this is alway true!
prepareToCommit in interface IResourceControllertx - the transaction context
IResourceController.prepareToCommit(com.xenonsoft.bridgetown.aop.transaction.ITransactionContext)public void commitResource(ITransactionContext tx)
commitResource in interface IResourceControllertx - the transaction contextIResourceController.commitResource(com.xenonsoft.bridgetown.aop.transaction.ITransactionContext)public void rollbackResource(ITransactionContext tx)
rollbackResource in interface IResourceControllertx - the transaction contextIResourceController.rollbackResource(com.xenonsoft.bridgetown.aop.transaction.ITransactionContext)public void closeResource(ITransactionContext tx)
closeResource in interface IResourceControllertx - the transaction contextIResourceController.closeResource(com.xenonsoft.bridgetown.aop.transaction.ITransactionContext)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||