KickJava   Java API By Example, From Geeks To Geeks.

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


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

22 public class TimerServiceMethodInjector implements Injector
23 {
24    private Method JavaDoc setMethod;
25    private Container container;
26
27    public TimerServiceMethodInjector(Method JavaDoc setMethod, Container container)
28    {
29       this.setMethod = setMethod;
30       this.container = container;
31    }
32
33    public void inject(BeanContext ctx)
34    {
35
36       Object JavaDoc[] args = {container.getTimerService()};
37       try
38       {
39          setMethod.invoke(ctx.getInstance(), args);
40       }
41       catch (IllegalAccessException JavaDoc e)
42       {
43          throw new RuntimeException JavaDoc(e); //To change body of catch statement use Options | File Templates.
44
}
45       catch (IllegalArgumentException JavaDoc e)
46       {
47          throw new RuntimeException JavaDoc("Failed in setting EntityManager on setter method: " + setMethod.toString());
48       }
49       catch (InvocationTargetException JavaDoc e)
50       {
51          throw new RuntimeException JavaDoc(e.getCause()); //To change body of catch statement use Options | File Templates.
52
}
53    }
54 }
55
Popular Tags