KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > alt > jiapi > instrumentor > MethodDispatcherInstrumentor


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.instrumentor;
20
21 import org.apache.log4j.Category;
22
23 import alt.jiapi.reflect.InstructionList;
24 import alt.jiapi.reflect.JiapiClass;
25 import alt.jiapi.reflect.JiapiMethod;
26 import alt.jiapi.Runtime;
27
28 /**
29  * MethodDispatcherInstrumentor forwards the chain for each method.
30  *
31  * @author Mika Riekkinen
32  * @author Joni Suominen
33  * @version $Revision: 1.3 $ $Date: 2004/03/15 14:47:53 $
34  */

35 public class MethodDispatcherInstrumentor extends AbstractInstrumentor {
36     private static Category log = Runtime.getLogCategory(MethodDispatcherInstrumentor.class);
37
38     public MethodDispatcherInstrumentor() {
39     }
40
41     public void instrument(InstructionList il) {
42         JiapiClass clazz = getCurrentClass();
43         JiapiMethod[] methods = clazz.getDeclaredMethods();
44
45         for (int i = 0; i < methods.length; i++) {
46             log.debug("dispatching for: " + methods[i].getName());
47             InstructionList _il = methods[i].getInstructionList();
48             forward(_il);
49         }
50     }
51 }
52
Popular Tags