KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > injection > TimerServiceFieldInjector


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

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.Field JavaDoc;
13
14 /**
15  * Comment
16  *
17  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
18  * @version $Revision: 1.2.2.2 $
19  *
20  **/

21 public class TimerServiceFieldInjector implements Injector
22 {
23    private Field JavaDoc field;
24    private Container container;
25
26    public TimerServiceFieldInjector(Field JavaDoc field, Container container)
27    {
28       this.field = field;
29       this.field.setAccessible(true);
30       this.container = container;
31    }
32
33    public void inject(BeanContext ctx)
34    {
35       try
36       {
37          field.set(ctx.getInstance(), container.getTimerService());
38       }
39       catch (IllegalAccessException JavaDoc e)
40       {
41          throw new RuntimeException JavaDoc(e); //To change body of catch statement use Options | File Templates.
42
}
43       catch (IllegalArgumentException JavaDoc e)
44       {
45          throw new RuntimeException JavaDoc("Failed in setting EntityManager on setter field: " + field.toString());
46       }
47    }
48 }
49
Popular Tags