com.xenonsoft.bridgetown.aop.transaction.jta
Class JtaTransactionServiceManager

java.lang.Object
  extended bycom.xenonsoft.bridgetown.aop.transaction.support.AbstractTransactionServiceManager
      extended bycom.xenonsoft.bridgetown.aop.transaction.jta.JtaTransactionServiceManager
All Implemented Interfaces:
IStartable, ITransactionServiceManager, java.io.Serializable

public class JtaTransactionServiceManager
extends AbstractTransactionServiceManager
implements java.io.Serializable, IStartable

A platform transaction service manager that specifically delegates to the Java Transaction API (JTA) and an external transaction manager. The transaction manager and the OTS (CORBA Object TransactionService) and the JTS (Java Transaction Service) are core components that are normally utilised by J2EE based application servers. The J2EE specification from version 1.3 onward, in fact, mandates that certain certain JTA API are available as standard in J2EE-compliant application server. This fact makes it possible to built an abstraction around the concept of platform transaction.

In terms of transaction, we mean transaction that follow the ACID principles. ACID stands for Atomicity, Consistency, Isolation and Durability. In general it is very complex to develop manually enterprise applications that strictly adhere to the ACID principles. The general practice is to delegate this responsibility to an external transaction service. The JTA API is an example of exposing such a enterprise component transaction manager to the Java platform.

Transaction services, then, are designed for transaction that are complex to write. Noteably such services are distributed in nature, in other words these transaction can involved multiple data sources, and across different processes and heterogeneous machines. A transaction that spans across such distributed systems is known as a global transaction.

This class is designed to allow Plain Old Java Objects (POJOS) to participate in global transactions JTA with the help of an aspect orient assember, of course. Using the AOP side of Bridgetown with the transaction method interceptor TransactionMethodInterceptor makes the process transparent. On the other hand the transaction management service is available to be programmed directly.

This class works best with the transaction session factory JtaTransactionSession and its corresponding context object JtaTransactionContext. Still a developer can invent his or her own configuration.

CAUTION: If the Jta transaction service manager is developed inside an Enterprise JavaBean then be sure to disable Container Managed Transactions, because most J2EE transactions service do not support nested transaction. This transaction service manager class, by default does not perform checks on application server transactions.

Version:
$Id: JtaTransactionServiceManager.java,v 1.5 2005/03/20 17:42:15 peter_pilgrim Exp $
Author:
Peter Pilgrim, 21-Feb-2005 19:08:34
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.xenonsoft.bridgetown.aop.transaction.support.AbstractTransactionServiceManager
AbstractTransactionServiceManager.ConfigStackThreadLocal, AbstractTransactionServiceManager.TxStackThreadLocal
 
Field Summary
protected  java.lang.String contextFactory
          JNDI context factory lookup
static java.lang.String DEFAULT_JNDI_USER_TRANSACTION
          Default jndi look up for JTA transaction javax.transaction.UserTransaction
protected  java.util.Properties environment
          JNDI provider environmental properties
protected  java.lang.String jndiUserTransaction
          Jndi look up for JTA transaction
protected  IObjectFactory managerFactory
          Object factory to create or retrieve the external JTA transaction manager from the application server or distributed resource.
protected  java.lang.String providerUrl
          JNDI provider URL
protected  java.lang.String securityCredentials
          JNDI provider password
protected  java.lang.String securityPrincipal
          JNDI provider username
 
Fields inherited from class com.xenonsoft.bridgetown.aop.transaction.support.AbstractTransactionServiceManager
configStackList, participantListeners, txStackList
 
Constructor Summary
JtaTransactionServiceManager()
          Default constructor
 
Method Summary
protected  void commitRollbackTx(TransactionObject tx, boolean commit)
          A refactored method for this implementation that attempts to commit or rollback the supplied transaction object.
protected  void executeCommitOrRollback(boolean commit, boolean debuggable, java.lang.String identifier, ITransactionConfig config, TransactionObject tx)
          A refactored method to commit or rollback the transaction object.
protected  TransactionObject executeCreate(ITransactionSession session, ITransactionConfig config, boolean debuggable, java.lang.String identifier)
          A refactored method to create a transaction context object.
protected  void executeResume(boolean debuggable, java.lang.String identifier, ITransactionConfig config, TransactionObject tx)
          A refactored method to resume a transaction object Subclasser cannot override this method to perform additional steps.
protected  void executeSuspend(ITransactionConfig config, boolean debuggable, java.lang.String identifier, TransactionObject tx)
          A refactored method to suspend an existing transaction context object.
protected  void forceRollbackTx(TransactionObject tx)
          A refactored method for this TM implementation that forces rollback of the transaction object.
 java.lang.String getContextFactory()
          Gets the contextFactory
 java.util.Properties getEnvironment()
          Gets the environment for the JNDI provider
 java.lang.String getJndiUserTransaction()
          Gets the jndiUserTransaction
 java.lang.String getProviderUrl()
          Gets the providerUrl
 java.lang.String getSecurityCredentials()
          Gets the securityCredentials
 java.lang.String getSecurityPrincipal()
          Gets the securityPrincipal
 javax.transaction.TransactionManager getTransactionManager()
          Retrieves the transaction manager
protected  javax.transaction.UserTransaction getUserTransaction()
          Retrieves the user transaction associated with the thread from JNDI lookup
 boolean isActive()
          Implements / overrides isActive.
 boolean isTransactionNew(ITransactionContext txRef)
          Implements / overrides isTransactionNew This call is not supported
 void setContextFactory(java.lang.String contextFactory)
          Sets the contextFactory
 void setEnvironment(java.util.Properties env)
          Sets the environment for the JNDI provider
 void setJndiUserTransaction(java.lang.String jndiUserTransaction)
          Sets the jndiUserTransaction
 void setProviderUrl(java.lang.String providerUrl)
          Sets the providerUrl
 void setSecurityCredentials(java.lang.String securityCredentials)
          Sets the securityCredentials
 void setSecurityPrincipal(java.lang.String securityPrincipal)
          Sets the securityPrincipal
 void start()
          Starts this object when loaded by a service object assembler By default this transaction manager is initially set up for Weblogic Server.
 java.lang.String toString()
          Reurns a human readable string.
 
Methods inherited from class com.xenonsoft.bridgetown.aop.transaction.support.AbstractTransactionServiceManager
addParticipiant, begin, commit, fireAfterBegin, fireBeforeCommit, fireBeforeRollback, getThreadName, getTransaction, removeParticipiant, resume, rollback, suspend, unallocate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_JNDI_USER_TRANSACTION

public static final java.lang.String DEFAULT_JNDI_USER_TRANSACTION
Default jndi look up for JTA transaction javax.transaction.UserTransaction

See Also:
Constant Field Values

jndiUserTransaction

protected java.lang.String jndiUserTransaction
Jndi look up for JTA transaction


contextFactory

protected java.lang.String contextFactory
JNDI context factory lookup


providerUrl

protected java.lang.String providerUrl
JNDI provider URL


securityPrincipal

protected java.lang.String securityPrincipal
JNDI provider username


securityCredentials

protected java.lang.String securityCredentials
JNDI provider password


environment

protected java.util.Properties environment
JNDI provider environmental properties


managerFactory

protected IObjectFactory managerFactory
Object factory to create or retrieve the external JTA transaction manager from the application server or distributed resource.

Constructor Detail

JtaTransactionServiceManager

public JtaTransactionServiceManager()
Default constructor

Method Detail

toString

public java.lang.String toString()
Reurns a human readable string. Implements / overrides toString

Returns:
See Also:
Object.toString()

getContextFactory

public java.lang.String getContextFactory()
Gets the contextFactory

Returns:
Returns the contextFactory.

setContextFactory

public void setContextFactory(java.lang.String contextFactory)
Sets the contextFactory

Parameters:
contextFactory - the new value for contextFactory

getEnvironment

public java.util.Properties getEnvironment()
Gets the environment for the JNDI provider

Returns:
Returns the environment.

setEnvironment

public void setEnvironment(java.util.Properties env)
Sets the environment for the JNDI provider


getJndiUserTransaction

public java.lang.String getJndiUserTransaction()
Gets the jndiUserTransaction

Returns:
Returns the jndiUserTransaction.

setJndiUserTransaction

public void setJndiUserTransaction(java.lang.String jndiUserTransaction)
Sets the jndiUserTransaction

Parameters:
jndiUserTransaction - the new value for jndiUserTransaction

getProviderUrl

public java.lang.String getProviderUrl()
Gets the providerUrl

Returns:
Returns the providerUrl.

setProviderUrl

public void setProviderUrl(java.lang.String providerUrl)
Sets the providerUrl

Parameters:
providerUrl - the new value for providerUrl

getSecurityCredentials

public java.lang.String getSecurityCredentials()
Gets the securityCredentials

Returns:
Returns the securityCredentials.

setSecurityCredentials

public void setSecurityCredentials(java.lang.String securityCredentials)
Sets the securityCredentials

Parameters:
securityCredentials - the new value for securityCredentials

getSecurityPrincipal

public java.lang.String getSecurityPrincipal()
Gets the securityPrincipal

Returns:
Returns the securityPrincipal.

setSecurityPrincipal

public void setSecurityPrincipal(java.lang.String securityPrincipal)
Sets the securityPrincipal

Parameters:
securityPrincipal - the new value for securityPrincipal

getUserTransaction

protected javax.transaction.UserTransaction getUserTransaction()
Retrieves the user transaction associated with the thread from JNDI lookup

Returns:
the user transaction

start

public void start()
Starts this object when loaded by a service object assembler

By default this transaction manager is initially set up for Weblogic Server.

Specified by:
start in interface IStartable
See Also:
IStartable.start()

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
                                                           throws TransactionException
Retrieves the transaction manager

Returns:
Throws:
TransactionException

isActive

public boolean isActive()
Implements / overrides isActive.

This call is not supported

Specified by:
isActive in interface ITransactionServiceManager
Specified by:
isActive in class AbstractTransactionServiceManager
Returns:
See Also:
ITransactionServiceManager.isActive()

isTransactionNew

public boolean isTransactionNew(ITransactionContext txRef)
                         throws TransactionException,
                                java.lang.IllegalArgumentException
Implements / overrides isTransactionNew

This call is not supported

Specified by:
isTransactionNew in interface ITransactionServiceManager
Specified by:
isTransactionNew in class AbstractTransactionServiceManager
Parameters:
txRef -
Returns:
Throws:
TransactionException
java.lang.IllegalArgumentException
See Also:
ITransactionServiceManager.isTransactionNew(com.xenonsoft.bridgetown.aop.transaction.ITransactionContext)

executeCreate

protected TransactionObject executeCreate(ITransactionSession session,
                                          ITransactionConfig config,
                                          boolean debuggable,
                                          java.lang.String identifier)
                                   throws TransactionException
A refactored method to create a transaction context object. Subclasser cannot override this method to perform additional steps.

Specified by:
executeCreate in class AbstractTransactionServiceManager
Parameters:
session - the transaction session factory
config - the transaction configuration
debuggable - if the logging debuggable flag is set
identifier - the transaction service identifier for logging
Returns:
the brand new transaction object
Throws:
TransactionException - if there is a transaction operation failure

executeSuspend

protected void executeSuspend(ITransactionConfig config,
                              boolean debuggable,
                              java.lang.String identifier,
                              TransactionObject tx)
                       throws TransactionException
A refactored method to suspend an existing transaction context object. Subclasser cannot override this method to perform additional steps.

Specified by:
executeSuspend in class AbstractTransactionServiceManager
Parameters:
config - the transaction configuration
debuggable - if the logging debuggable flag is set
identifier - the transaction service identifier for logging
tx - the transaction object that represents a transaction context to suspend
Throws:
TransactionException - if there is a transaction operation failure

executeCommitOrRollback

protected void executeCommitOrRollback(boolean commit,
                                       boolean debuggable,
                                       java.lang.String identifier,
                                       ITransactionConfig config,
                                       TransactionObject tx)
                                throws TransactionException
A refactored method to commit or rollback the transaction object. Subclasser cannot override this method to perform additional steps.

Specified by:
executeCommitOrRollback in class AbstractTransactionServiceManager
Parameters:
commit - if true then attempt to commit transaction otherwise rollback
debuggable - the debuggable flag if this method writes to logger
identifier - the transaction service manager identifier
config - the transaction configuration
tx - the transaction context
Throws:
TransactionException - if there is a transaction operation failure

executeResume

protected void executeResume(boolean debuggable,
                             java.lang.String identifier,
                             ITransactionConfig config,
                             TransactionObject tx)
                      throws TransactionException
A refactored method to resume a transaction object Subclasser cannot override this method to perform additional steps.

Specified by:
executeResume in class AbstractTransactionServiceManager
Parameters:
debuggable - the debuggable flag if this method writes to logger
identifier - the transaction service manager identifier
config - the transaction configuration
tx - the transaction context
Throws:
TransactionException - if there is a transaction operation failure

commitRollbackTx

protected void commitRollbackTx(TransactionObject tx,
                                boolean commit)
                         throws TransactionException
A refactored method for this implementation that attempts to commit or rollback the supplied transaction object.

Specified by:
commitRollbackTx in class AbstractTransactionServiceManager
Parameters:
tx - the transaction object
commit - if true then attempt to commit transaction otherwise rollback
Throws:
TransactionException - if there is a transaction operation failure

forceRollbackTx

protected void forceRollbackTx(TransactionObject tx)
                        throws TransactionException
A refactored method for this TM implementation that forces rollback of the transaction object.

Specified by:
forceRollbackTx in class AbstractTransactionServiceManager
Parameters:
tx - the transaction object
Throws:
TransactionException - if there is a transaction operation failure


Copyright © 2005 XeNoNSoFT.com. All Rights Reserved.