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

TxInterceptorFactory

public class TxInterceptorFactory extends Object implements org.jboss.aop.advice.AspectFactory
This interceptor handles transactions for AOP
author
Bill Burke
version
$Revision: 57186 $

Fields Summary
protected TxPolicy
policy
protected HashMap
nameMap
Constructors Summary
Methods Summary
public java.lang.ObjectcreatePerClass(org.jboss.aop.Advisor advisor)

      throw new IllegalStateException("Scope not allowed");
   
public java.lang.ObjectcreatePerInstance(org.jboss.aop.Advisor advisor, org.jboss.aop.InstanceAdvisor instanceAdvisor)

      throw new IllegalStateException("Scope not allowed");
   
public java.lang.ObjectcreatePerJoinpoint(org.jboss.aop.Advisor advisor, org.jboss.aop.joinpoint.Joinpoint jp)

      initialize();
      String txType = resolveTxType(advisor, jp);
      Object rtn = nameMap.get(txType.toUpperCase());
      if (rtn == null) throw new RuntimeException("TX TYPE was null for: " + txType);
      return rtn;
   
public java.lang.ObjectcreatePerJoinpoint(org.jboss.aop.Advisor advisor, org.jboss.aop.InstanceAdvisor instanceAdvisor, org.jboss.aop.joinpoint.Joinpoint jp)

      throw new IllegalStateException("Scope not allowed");
   
public java.lang.ObjectcreatePerVM()

      throw new IllegalStateException("Scope not allowed");
   
public java.lang.StringgetName()

      return getClass().getName();
   
public voidinitialize()

      if (policy != null) return;
      initializePolicy();
      nameMap.put("NEVER", new TxInterceptor.Never(TransactionManagerLocator.getInstance().locate(), policy));
      nameMap.put("NOTSUPPORTED", new TxInterceptor.NotSupported(TransactionManagerLocator.getInstance().locate(), policy));
      nameMap.put("SUPPORTS", new TxInterceptor.Supports(TransactionManagerLocator.getInstance().locate(), policy));
      nameMap.put("REQUIRED", new TxInterceptor.Required(TransactionManagerLocator.getInstance().locate(), policy));
      nameMap.put("REQUIRESNEW", new TxInterceptor.RequiresNew(TransactionManagerLocator.getInstance().locate(), policy));
      nameMap.put("MANDATORY", new TxInterceptor.Mandatory(TransactionManagerLocator.getInstance().locate(), policy));
   
protected voidinitializePolicy()


     
   
      policy = new TxPolicy();
   
protected java.lang.StringresolveTxType(org.jboss.aop.Advisor advisor, org.jboss.aop.joinpoint.Joinpoint jp)

      if (jp instanceof ConstructorJoinpoint)
      {
         Constructor con = ((ConstructorJoinpoint)jp).getConstructor();
         String txType = (String)advisor.getConstructorMetaData().getConstructorMetaData(con, "transaction", "trans-attribute");
         if (txType != null) return txType;

         txType = (String)advisor.getDefaultMetaData().getMetaData("transaction", "trans-attribute");
         if (txType != null) return txType;

         Tx tx = (Tx)advisor.resolveAnnotation(con, Tx.class);
         if (tx == null)
         {
            tx = (Tx)advisor.resolveAnnotation(Tx.class);
         }
         if (tx == null) return "REQUIRED";
         return tx.value().name();
      }
      else if (jp instanceof MethodJoinpoint)
      {
         Method con = ((MethodJoinpoint)jp).getMethod();
         String txType = (String)advisor.getMethodMetaData().getMethodMetaData(con, "transaction", "trans-attribute");
         if (txType != null) return txType;

         txType = (String)advisor.getDefaultMetaData().getMetaData("transaction", "trans-attribute");
         if (txType != null) return txType;

         Tx tx = (Tx)advisor.resolveAnnotation(con, Tx.class);
         if (tx == null)
         {
            tx = (Tx)advisor.resolveAnnotation(Tx.class);
         }
         if (tx == null) return "REQUIRED";
         return tx.value().name();
      }
      else
      {
         Field con = ((FieldJoinpoint)jp).getField();
         String txType = (String)advisor.getFieldMetaData().getFieldMetaData(con, "transaction", "trans-attribute");
         if (txType != null) return txType;

         txType = (String)advisor.getDefaultMetaData().getMetaData("transaction", "trans-attribute");
         if (txType != null) return txType;

         Tx tx = (Tx)advisor.resolveAnnotation(con, Tx.class);
         if (tx == null)
         {
            tx = (Tx)advisor.resolveAnnotation(Tx.class);
         }
         if (tx == null) return "REQUIRED";
         return tx.value().name();
      }