1 22 package org.jboss.injection; 23 24 import java.lang.reflect.Field ; 25 import org.jboss.ejb3.BeanContext; 26 import org.jboss.ejb3.Container; 27 28 34 public class TimerServiceFieldInjector implements Injector 35 { 36 private Field field; 37 private Container container; 38 39 public TimerServiceFieldInjector(Field field, Container container) 40 { 41 this.field = field; 42 this.field.setAccessible(true); 43 this.container = container; 44 } 45 46 public void inject(Object instance) 47 { 48 throw new RuntimeException ("SHOULD NOT BE INVOKED"); 49 } 50 51 public void inject(BeanContext ctx) 52 { 53 try 54 { 55 field.set(ctx.getInstance(), container.getTimerService()); 56 } 57 catch (IllegalAccessException e) 58 { 59 throw new RuntimeException (e); } 61 catch (IllegalArgumentException e) 62 { 63 throw new RuntimeException ("Failed in setting EntityManager on setter field: " + field.toString()); 64 } 65 } 66 67 public Class getInjectionClass() 68 { 69 return field.getType(); 70 } 71 } 72 | Popular Tags |