|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xenonsoft.bridgetown.aop.transaction.support.JNDIDataSourceResourceController
An implementation of a data source resource controller for global
transaction support. This resource controller, obviously,
works with both XA and non-XA connections, because the retrieval
of such data sources is defined by the application server
configuration and EAR administration. The class retrieves
a data source from JNDI provider, which can be externally
configured from the environment properties
setEnvironment(Properties).
This resource controller does not implement the suspension or
resumption of resources; nor does it explicitly call commit
Connection.commit() or rollback
Connection.rollback() or change
the auto commit mode
Connection.setAutoCommit(boolean)
on JDBC connections
because such calls are prohibited by the JTA specification.
Use this class with the JTA (platform) transaction
service manager JtaTransactionServiceManager,
which is specifically designed to delegate calls to a
true JTA transaction manager implementation.
In order to use to this lookup bean simply define environment properties for your particular application server.
The following defines a secure WebLogic JNDI Provider:
java.naming.factory.initial = weblogic.jndi.WLInitialContextFactory java.naming.provider.url = t3://localhost:7001 java.naming.security.principal = username java.naming.security.credentials = password java.naming.security.protocol = ssl
The last three properties are optional, for example, if the
JNDI provider is not secured by a login user and obviously SSL.
These values would, then, become the environment
property for this object.
The lookupName defines the name of the data source
to retrieve from the JNDI provider. 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)
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 java.sql.Connection |
connection
JDBC connection |
protected javax.sql.DataSource |
dataSource
JDBC data source |
protected java.util.Properties |
environment
The properties optionally defined for JNDI initial context |
protected java.lang.String |
lookupName
The name bean to retrieve using JNDI |
protected TransactionIsolationEnum |
requestedIsolationLevel
Requested isolation level |
protected int |
requestedTransactionTimeout
Requested transaction timeout |
| Constructor Summary | |
JNDIDataSourceResourceController()
Default constructor |
|
JNDIDataSourceResourceController(java.lang.String lookupName)
Standard constructor |
|
JNDIDataSourceResourceController(java.lang.String lookupName,
java.util.Properties environment)
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 |
java.util.Properties |
getEnvironment()
Gets the environment for accessing the JNDI provider |
java.lang.String |
getLookupName()
Gets the name of the data source to be looked up in JNDI |
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 |
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 |
setEnvironment(java.util.Properties environment)
Sets the environment for accessing the JNDI provider |
void |
setLookupName(java.lang.String lookupName)
Sets the name of the data source to be looked up in JNDI |
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 java.lang.String lookupName
protected java.util.Properties environment
protected transient javax.sql.DataSource dataSource
protected transient java.sql.Connection connection
protected TransactionIsolationEnum requestedIsolationLevel
protected int requestedTransactionTimeout
| Constructor Detail |
public JNDIDataSourceResourceController()
public JNDIDataSourceResourceController(java.lang.String lookupName)
lookupName - the lookup name for retrieving the data source from JNDI provider
public JNDIDataSourceResourceController(java.lang.String lookupName,
java.util.Properties environment)
lookupName - the lookup name for retrieving the data source from JNDI providerenvironment - the JNDI provider environment| Method Detail |
public java.lang.String toString()
Object.toString()public java.util.Properties getEnvironment()
public void setEnvironment(java.util.Properties environment)
environment - the new value for environmentpublic java.lang.String getLookupName()
public void setLookupName(java.lang.String lookupName)
lookupName - the new value for lookupNamepublic javax.sql.DataSource getDataSource()
public java.sql.Connection getConnection()
public TransactionIsolationEnum getRequestedIsolationLevel()
public void setRequestedIsolationLevel(TransactionIsolationEnum requestedIsolationLevel)
setRequestedIsolationLevel in interface IResourceControllerrequestedIsolationLevel - The requestedIsolationLevel to set.public int getRequestedTransactionTimeout()
public void setRequestedTransactionTimeout(int requestedTransactionTimeout)
NB:
This value is not used at all, because the Setting the
timeout of the current global transaction timeout is the
responsibility of the Jta TSM
JtaTransactionServiceManager
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 JTA transactions this is alway true!
prepareToCommit in interface IResourceControllertx - the transaction context
true to indicate to platform
transaction service manager that the underlying
transaction should commit.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 | |||||||||