01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */
05: package org.terracotta.modules.hibernate_3_1_2;
06:
07: import com.tc.asm.ClassAdapter;
08: import com.tc.asm.ClassVisitor;
09: import com.tc.asm.Label;
10: import com.tc.asm.MethodVisitor;
11: import com.tc.asm.Opcodes;
12: import com.tc.object.bytecode.ClassAdapterFactory;
13:
14: public class EhcacheProviderClassAdapter extends ClassAdapter implements
15: ClassAdapterFactory, Opcodes {
16: public EhcacheProviderClassAdapter() {
17: super (null);
18: }
19:
20: private EhcacheProviderClassAdapter(ClassVisitor cv) {
21: super (cv);
22: }
23:
24: public ClassAdapter create(ClassVisitor visitor, ClassLoader loader) {
25: return new EhcacheProviderClassAdapter(visitor);
26: }
27:
28: public MethodVisitor visitMethod(int access, String name,
29: String desc, String signature, String[] exceptions) {
30: if ("stop".equals(name) && "()V".equals(desc)) {
31: recreateStopMethod(access, name, desc, signature,
32: exceptions);
33: return null;
34: } else {
35: return super .visitMethod(access, name, desc, signature,
36: exceptions);
37: }
38: }
39:
40: private void recreateStopMethod(int access, String name,
41: String desc, String signature, String[] exceptions) {
42: MethodVisitor mv = cv.visitMethod(access, name, desc,
43: signature, exceptions);
44: mv.visitCode();
45: Label l0 = new Label();
46: mv.visitLabel(l0);
47: mv.visitLineNumber(150, l0);
48: mv.visitInsn(RETURN);
49: Label l1 = new Label();
50: mv.visitLabel(l1);
51: mv.visitLocalVariable("this",
52: "Lorg/hibernate/cache/EhCacheProvider;", null, l0, l1,
53: 0);
54: mv.visitMaxs(0, 1);
55: mv.visitEnd();
56: }
57: }
|