KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > cglib > proxy > FixedValueGenerator


1 /*
2  * Copyright 2003,2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package net.sf.cglib.proxy;
17
18 import java.util.*;
19 import net.sf.cglib.core.*;
20 import org.objectweb.asm.Type;
21
22 class FixedValueGenerator implements CallbackGenerator {
23     public static final FixedValueGenerator INSTANCE = new FixedValueGenerator();
24     private static final Type FIXED_VALUE =
25       TypeUtils.parseType("net.sf.cglib.proxy.FixedValue");
26     private static final Signature LOAD_OBJECT =
27       TypeUtils.parseSignature("Object loadObject()");
28
29     public void generate(ClassEmitter ce, Context context, List methods) {
30         for (Iterator it = methods.iterator(); it.hasNext();) {
31             MethodInfo method = (MethodInfo)it.next();
32             CodeEmitter e = context.beginMethod(ce, method);
33             context.emitCallback(e, context.getIndex(method));
34             e.invoke_interface(FIXED_VALUE, LOAD_OBJECT);
35             e.unbox_or_zero(e.getReturnType());
36             e.return_value();
37             e.end_method();
38         }
39     }
40
41     public void generateStatic(CodeEmitter e, Context context, List methods) { }
42 }
43
Popular Tags