KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > jmx > julia > stat > StatCodeGenerator


1 /***
2  * Fractal JMX
3  * Copyright (C) 2003 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: fractal@objectweb.org
20  *
21  * Authors: Eric Bruneton
22  */

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

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