1 54 package org.logicalcobwebs.cglib.proxy; 55 56 import java.lang.reflect.Method ; 57 import java.lang.reflect.Modifier ; 58 import java.util.*; 59 import org.logicalcobwebs.cglib.core.*; 60 import org.logicalcobwebs.asm.Type; 61 62 class DispatcherGenerator implements CallbackGenerator { 63 public static final DispatcherGenerator INSTANCE = new DispatcherGenerator(); 64 65 private static final Type DISPATCHER = 66 TypeUtils.parseType("org.logicalcobwebs.cglib.proxy.Dispatcher"); 67 private static final Signature LOAD_OBJECT = 68 TypeUtils.parseSignature("Object loadObject()"); 69 70 public void generate(ClassEmitter ce, final Context context) { 71 for (Iterator it = context.getMethods(); it.hasNext();) { 72 Method method = (Method )it.next(); 73 if (Modifier.isProtected(method.getModifiers())) { 74 } else { 76 CodeEmitter e = ce.begin_method(context.getModifiers(method), 77 ReflectUtils.getSignature(method), 78 ReflectUtils.getExceptionTypes(method), 79 null); 80 context.emitCallback(e, context.getIndex(method)); 81 e.invoke_interface(DISPATCHER, LOAD_OBJECT); 82 e.checkcast(Type.getType(method.getDeclaringClass())); 83 e.load_args(); 84 e.invoke(method); 85 e.return_value(); 86 e.end_method(); 87 } 88 } 89 } 90 91 public void generateStatic(CodeEmitter e, Context context) { } 92 } 93 | Popular Tags |