1 16 package net.sf.cglib.transform.hook; 17 18 import net.sf.cglib.core.*; 19 import net.sf.cglib.transform.*; 20 import org.objectweb.asm.Attribute; 21 import org.objectweb.asm.Type; 22 23 public class ExamplePreProcessor extends AbstractPreProcessor { 24 private static final Type PRINT_STREAM = 25 TypeUtils.parseType("java.io.PrintStream"); 26 private static final Signature PRINTLN = 27 TypeUtils.parseSignature("void println(String)"); 28 29 protected ClassTransformer getClassTransformer(String name) { 30 return new ClassEmitterTransformer() { 31 public CodeEmitter begin_method(int access, Signature sig, Type[] exceptions, Attribute attrs) { 32 CodeEmitter e = super.begin_method(access, sig, exceptions, attrs); 33 if (!TypeUtils.isAbstract(access)) { 34 e.getstatic(Constants.TYPE_SYSTEM, "err", PRINT_STREAM); 35 e.push("Running " + sig.getName() + sig.getDescriptor()); 36 e.invoke_virtual(PRINT_STREAM, PRINTLN); 37 } 38 return e; 39 } 40 }; 41 } 42 } 43 | Popular Tags |