1 7 package org.jboss.ejb3.injection; 8 9 import org.jboss.ejb3.BeanContext; 10 11 import java.lang.reflect.InvocationTargetException ; 12 import java.lang.reflect.Method ; 13 14 20 public class EJBContextMethodInjector implements Injector 21 { 22 private Method setMethod; 23 24 public EJBContextMethodInjector(Method setMethod) 25 { 26 this.setMethod = setMethod; 27 } 28 29 public void inject(BeanContext ctx) 30 { 31 32 Object [] args = {ctx}; 33 try 34 { 35 setMethod.invoke(ctx.getInstance(), args); 36 } 37 catch (IllegalAccessException e) 38 { 39 throw new RuntimeException (e); } 41 catch (IllegalArgumentException e) 42 { 43 throw new RuntimeException ("Failed in setting EntityManager on setter method: " + setMethod.toString()); 44 } 45 catch (InvocationTargetException e) 46 { 47 throw new RuntimeException (e.getCause()); } 49 } 50 } 51 | Popular Tags |