com.xenonsoft.bridgetown.aop.transaction.support
Class TransactionMethodInterceptor

java.lang.Object
  extended bycom.xenonsoft.bridgetown.aop.transaction.support.TransactionMethodInterceptor
All Implemented Interfaces:
IMethodInterceptor, java.io.Serializable

public class TransactionMethodInterceptor
extends java.lang.Object
implements IMethodInterceptor, java.io.Serializable

Transaction method interceptor class that advises a target bean. This interceptor has the ability to inject transactional resources into the target bean using a Java Bean property name as the key.

BeanUtils Property Name resource controller name Equivalent Java Language Statement
payrollConnection payrollDB targetBean.setPayrollConnection( IResourceController )
a.b(Xanadu).salesConnection msgDB targetBean.getA().getB("Xanadu").setSalesConnection( IResourceController )
x.y[3].counterparyConnection cptyDB targetBean.getX().getY(3).setCounterpartyConnection( IResourceController )

If the inteception method returns normally then the transaction is committed.

If the interception method returns abnormally by raising an exception, then the transaction is rolled back.

Regardlessly of normal or abnormal execution, the connection is alway released after used. If the close on release flag is set, the connection will be closed.

Version:
$Id: TransactionMethodInterceptor.java,v 1.4 2005/03/17 02:49:58 peter_pilgrim Exp $
Author:
Peter Pilgrim, 16-Feb-2005 22:48:31
See Also:
Serialized Form

Field Summary
protected  java.util.Map resourceControllers
          A map collection of resource controllers associated by name.
protected  java.util.Map resourceProperties
          A map collection of resource controller names associated with target bean properties.
protected  ITransactionServiceManager transactionManager
          The transaction service manager injected into this object by the IoC container.
protected  ITransactionSession transactionSession
          The transaction session injected into this object by the IoC container.
 
Constructor Summary
TransactionMethodInterceptor()
          Default constructor
 
Method Summary
 java.util.Map getResourceControllers()
          Gets the map collection of resource controllers associated by name.
 java.util.Map getResourceProperties()
          Gets the map collection of resource controller names associated with target bean properties.
 ITransactionServiceManager getTransactionManager()
          Gets the transaction service manager
 ITransactionSession getTransactionSession()
          Gets the transaction session
protected  void injectResourceControllers(java.lang.Object targetBean)
          Inject the resource controller into the target bean using the supplied setter property names
 java.lang.Object invocation(IInterceptionContext context)
          Implements / overrides invocation
 void setResourceControllers(java.util.Map resourceControllers)
          Sets the map collection of resource controllers associated by name.
 void setResourceProperties(java.util.Map resourceProperties)
          Sets the map collection of resource controller names associated with target bean properties.
 void setTransactionManager(ITransactionServiceManager transactionManager)
          Sets the transaction service manager
 void setTransactionSession(ITransactionSession session)
          Sets the transaction session
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

transactionSession

protected ITransactionSession transactionSession
The transaction session injected into this object by the IoC container. The session is used to create transaction context associated with the target bean.


transactionManager

protected ITransactionServiceManager transactionManager
The transaction service manager injected into this object by the IoC container. The interceptor requires the use of the transaction manager to demarcate the transaction. (Demarcate means begin and complete, either commit all or rollback all )


resourceControllers

protected java.util.Map resourceControllers
A map collection of resource controllers associated by name. A transaction, more often than not, is associated with one or more resource controllers (database connection).


resourceProperties

protected java.util.Map resourceProperties
A map collection of resource controller names associated with target bean properties. In order, for this interceptor, to inject a resource controller in the advised target bean, it needs to know what mutator properties is related to which resource controller.

Constructor Detail

TransactionMethodInterceptor

public TransactionMethodInterceptor()
Default constructor

Method Detail

getResourceControllers

public java.util.Map getResourceControllers()
Gets the map collection of resource controllers associated by name.

Returns:
Returns the resourceControllers.

setResourceControllers

public void setResourceControllers(java.util.Map resourceControllers)
Sets the map collection of resource controllers associated by name.

Parameters:
resourceControllers - the new value for resourceControllers

getResourceProperties

public java.util.Map getResourceProperties()
Gets the map collection of resource controller names associated with target bean properties.

Returns:
Returns the resourceProperties.

setResourceProperties

public void setResourceProperties(java.util.Map resourceProperties)
Sets the map collection of resource controller names associated with target bean properties.

Parameters:
resourceProperties - the new value for resourceProperties

getTransactionSession

public ITransactionSession getTransactionSession()
Gets the transaction session

Returns:
Returns the session.

setTransactionSession

public void setTransactionSession(ITransactionSession session)
Sets the transaction session

Parameters:
session - the new value for session

getTransactionManager

public ITransactionServiceManager getTransactionManager()
Gets the transaction service manager

Returns:
Returns the transactionManager.

setTransactionManager

public void setTransactionManager(ITransactionServiceManager transactionManager)
Sets the transaction service manager

Parameters:
transactionManager - the new value for transactionManager

invocation

public java.lang.Object invocation(IInterceptionContext context)
                            throws java.lang.Throwable
Implements / overrides invocation

Specified by:
invocation in interface IMethodInterceptor
Parameters:
context -
Returns:
Throws:
java.lang.Throwable
See Also:
IMethodInterceptor.invocation(com.xenonsoft.bridgetown.aop.IInterceptionContext)

injectResourceControllers

protected void injectResourceControllers(java.lang.Object targetBean)
Inject the resource controller into the target bean using the supplied setter property names

Parameters:
targetBean - the target bean


Copyright © 2005 XeNoNSoFT.com. All Rights Reserved.