FileDocCategorySizeDatePackage
TxUtil.javaAPI DocJBoss 4.2.13784Fri Jul 13 20:53:54 BST 2007org.jboss.ejb3.tx

TxUtil

public class TxUtil extends Object
Comment
author
Bill Burke
version
$Revision: 60411 $

Fields Summary
Constructors Summary
Methods Summary
public static javax.ejb.ApplicationExceptiongetApplicationException(java.lang.Class exceptionClass, org.jboss.aop.joinpoint.Invocation invocation)

      MethodInvocation ejb = (MethodInvocation) invocation;
      EJBContainer container = (EJBContainer) ejb.getAdvisor();

      if (exceptionClass.isAnnotationPresent(ApplicationException.class))
         return (ApplicationException)exceptionClass.getAnnotation(ApplicationException.class);

      AssemblyDescriptor assembly = container.getAssemblyDescriptor();

      if (assembly != null)
      {
         List exceptions = assembly.getApplicationExceptions();
         if (exceptions.size() > 0)
         {
            Iterator exceptionIterator = exceptions.iterator();
            while (exceptionIterator.hasNext())
            {
               org.jboss.ejb3.metamodel.ApplicationException exception = (org.jboss.ejb3.metamodel.ApplicationException)exceptionIterator.next();
               if (exception.getExceptionClass().equals(exceptionClass.getName()))
                  return new ApplicationExceptionImpl(exception.getRollback());
            }
         }

      }
      return null;
   
public static javax.ejb.TransactionManagementTypegetTransactionManagementType(org.jboss.aop.Advisor c)

      TransactionManagement transactionManagement = (TransactionManagement) c.resolveAnnotation(TransactionManagement.class);
      if (transactionManagement == null) return TransactionManagementType.CONTAINER;
      return transactionManagement.value();
   
public static javax.transaction.TransactionManagergetTransactionManager()

      try
      {
         //return TxManager.getInstance();
         InitialContext jndiContext = InitialContextFactory.getInitialContext();
         TransactionManager tm = TransactionManagerLocator.getInstance().locate();
         return tm;
      } 
      catch (NamingException e)
      {
         throw new RuntimeException("Unable to lookup TransactionManager", e);
      }