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

UserTransactionFieldInjector

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

Fields Summary
private Field
field
Constructors Summary
public UserTransactionFieldInjector(Field field, 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.field = field;
      this.field.setAccessible(true);
   
Methods Summary
public java.lang.ClassgetInjectionClass()

      return field.getType();
   
public voidinject(org.jboss.ejb3.BeanContext ctx)

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

      UserTransaction ut = new UserTransactionImpl();
      try
      {
         field.set(instance, ut);
      }
      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 field: " + field.toString());
      }