1 package net.sf.cglib.transform.hook;
2
3 import net.sf.cglib.core.*;
4 import net.sf.cglib.transform.*;
5 import org.objectweb.asm.Attribute;
6 import org.objectweb.asm.Type;
7
8 public class ExamplePreProcessor extends AbstractPreProcessor {
9 private static final Type PRINT_STREAM =
10 TypeUtils.parseType("java.io.PrintStream");
11 private static final Signature PRINTLN =
12 TypeUtils.parseSignature("void println(String)");
13
14 protected ClassTransformer getClassTransformer(String name) {
15 return new ClassEmitterTransformer() {
16 public CodeEmitter begin_method(int access, Signature sig, Type[] exceptions, Attribute attrs) {
17 CodeEmitter e = super.begin_method(access, sig, exceptions, attrs);
18 if (!TypeUtils.isAbstract(access)) {
19 e.getstatic(Constants.TYPE_SYSTEM, "err", PRINT_STREAM);
20 e.push("Running " + sig.getName() + sig.getDescriptor());
21 e.invoke_virtual(PRINT_STREAM, PRINTLN);
22 }
23 return e;
24 }
25 };
26 }
27 }
This page was automatically generated by Maven