FileDocCategorySizeDatePackage
UserTransactionMethodInjector.javaAPI DocJBoss 4.2.13134Fri Jul 13 20:53:46 BST 2007org.jboss.injection

UserTransactionMethodInjector

public class UserTransactionMethodInjector extends Object implements Injector
Comment
author
Bill Burke
version
$Revision: 60233 $
deprecated
use UserTransactionPropertyInjector

Fields Summary
private Method
setMethod
Constructors Summary
public UserTransactionMethodInjector(Method setMethod, InjectionContainer container)

      if (container instanceof Container)
      {
         TransactionManagementType type = TxUtil.getTransactionManagementType(((Advisor) container));
         if (type != TransactionManagementType.BEAN)
            throw new IllegalStateException("Container " + ((Container) container).getEjbName() + ": it is illegal to inject UserTransaction into a CMT bean");
      }
      this.setMethod = setMethod;
      setMethod.setAccessible(true);
   
Methods Summary
public java.lang.ClassgetInjectionClass()

      return setMethod.getParameterTypes()[0];
   
public voidinject(org.jboss.ejb3.BeanContext ctx)

      Object instance = ctx.getInstance();
      inject(instance);
   
public voidinject(java.lang.Object instance)

      UserTransaction ut = new UserTransactionImpl();
      Object[] args = {ut};
      try
      {
         setMethod.invoke(instance, args);
      }
      catch (IllegalAccessException e)
      {
         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
      }
      catch (IllegalArgumentException e)
      {
         throw new RuntimeException("Failed in setting EntityManager on setter method: " + setMethod.toString());
      }
      catch (InvocationTargetException e)
      {
         throw new RuntimeException(e.getCause());  //To change body of catch statement use Options | File Templates.
      }