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