FileDocCategorySizeDatePackage
TransactionManagerInjector.javaAPI DocJBoss 4.2.12922Fri Jul 13 21:02:30 BST 2007org.jboss.aspects.tx

TransactionManagerInjector

public class TransactionManagerInjector extends Object
This aspect should be scoped PER_JOINPOINT It allows a field to be like a ThreadLocal
author
Bill Burke
version
$Revision: 57186 $

Fields Summary
Constructors Summary
Methods Summary
public java.lang.Objectaccess(org.jboss.aop.joinpoint.FieldReadInvocation invocation)

      return TransactionManagerLocator.getInstance().locate();
   
public java.lang.Objectaccess(org.jboss.aop.joinpoint.FieldWriteInvocation invocation)

      throw new RuntimeException("It is illegal to set an injected TransactionManager field.");
   
public java.lang.Objectallocation(org.jboss.aop.joinpoint.ConstructorInvocation invocation)

      Object obj = invocation.invokeNext();

      try
      {
         Object[] arg = {TransactionManagerLocator.getInstance().locate()};
         Method[] methods = obj.getClass().getMethods();
         for (int i = 0; i < methods.length; i++)
         {
            if (methods[i].getParameterTypes().length == 1)
            {
               if (methods[i].getParameterTypes()[0].equals(TransactionManager.class))
               {
                  if (AnnotationElement.isAnyAnnotationPresent(methods[i], Injected.class))
                  {
                     methods[i].invoke(obj, arg);
                  }
               }
            }
         }
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
      }
      return obj;