KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > stat > StatCodeGenerator


1 /***
2  * Julia: France Telecom's implementation of the Fractal API
3  * Copyright (C) 2001-2002 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: Eric.Bruneton@rd.francetelecom.com
20  *
21  * Author: Eric Bruneton
22  */

23
24 package stat;
25
26 import org.objectweb.fractal.julia.asm.SimpleCodeGenerator;
27
28 import java.lang.reflect.Method JavaDoc;
29
30 /**
31  * This code generator generates interception code of the following form for
32  * all methods:
33  *
34  * <p><pre>
35  * <i>method-signature</i> {
36  * <i>return-type</i> result;
37  * long context = delegate.preMethod(<i>method-name</i>);
38  * // original method code, where returns are replaced with gotos
39  * delegate.postMethod(<i>method-name</i>, context);
40  * return result;
41  * }
42  * </pre>
43  *
44  * where <tt>delegate</tt> is initialized with the following code:
45  *
46  * <p><pre>
47  * delegate = (...)ic.getInterface("stat-controller");
48  * </pre>
49  */

50
51 public class StatCodeGenerator extends SimpleCodeGenerator {
52
53   protected String JavaDoc getControllerInterfaceName () {
54     return "stat-controller";
55   }
56
57   protected String JavaDoc getPreMethodName () {
58     return "preMethod";
59   }
60
61   protected String JavaDoc getPostMethodName () {
62     return "postMethod";
63   }
64
65   protected Class JavaDoc getContextType () {
66     return Long.TYPE;
67   }
68
69   protected String JavaDoc getMethodName (final Method JavaDoc m) {
70     return m.getName();
71   }
72 }
73
Popular Tags