KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > alt > jiapi > event > MethodExitHook


1 /*
2  * Copyright(C) 2001 Mika Riekkinen, Joni Suominen
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or(at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package alt.jiapi.event;
20
21 import java.lang.reflect.Method JavaDoc;
22 import alt.jiapi.instrumentor.Hook;
23
24
25 /**
26  * Class used for internal purposes
27  *
28  * @author Mika Riekkinen
29  * @author Joni Suominen
30  * @version $Revision: 1.6 $ $Date: 2002/03/12 16:14:54 $
31  */

32 class MethodExitHook implements Hook {
33     private Method JavaDoc hookMethod;
34     private Object JavaDoc instance;
35
36     public MethodExitHook(MethodEventProducer mep) {
37         this.instance = mep;
38         Class JavaDoc [] params = new Class JavaDoc [] {Object JavaDoc.class, String JavaDoc.class};
39         try {
40             this.hookMethod =
41                 MethodEventProducer.class.getMethod("methodExited", params);
42         }
43         catch (Exception JavaDoc e) {
44             // not possible, but just in case
45
e.printStackTrace();
46             throw new RuntimeException JavaDoc(e.toString());
47         }
48     }
49
50     public Method JavaDoc getHookMethod() {
51         return hookMethod;
52     }
53
54     public Object JavaDoc getInstance() {
55         return instance;
56     }
57 }
58
Popular Tags