01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package org.terracotta.modules.wicket_1_3_0;
05:
06: import com.tc.asm.ClassAdapter;
07: import com.tc.asm.ClassVisitor;
08: import com.tc.asm.Label;
09: import com.tc.asm.MethodVisitor;
10: import com.tc.asm.Opcodes;
11: import com.tc.object.bytecode.ClassAdapterFactory;
12:
13: /**
14: * Custom adapter used to replace <code>ISessionStore</code> implementation in <code>WebApplication</code>.
15: *
16: * @see wicket.protocol.http.WebApplication.newSessionStore()
17: *
18: * @author Eugene Kuleshov
19: */
20: public class WicketWebApplicationAdapter extends ClassAdapter implements
21: Opcodes, ClassAdapterFactory {
22:
23: public WicketWebApplicationAdapter() {
24: super (null);
25: }
26:
27: public WicketWebApplicationAdapter(ClassVisitor visitor,
28: ClassLoader loader) {
29: super (visitor);
30: }
31:
32: public ClassAdapter create(ClassVisitor visitor, ClassLoader loader) {
33: return new WicketWebApplicationAdapter(visitor, loader);
34: }
35:
36: public MethodVisitor visitMethod(int access, String name,
37: String desc, String signature, String[] exceptions) {
38: MethodVisitor mv = super .visitMethod(access, name, desc,
39: signature, exceptions);
40:
41: if (!"newSessionStore".equals(name)
42: || !"()Lorg/apache/wicket/session/ISessionStore;"
43: .equals(desc)) {
44: return mv;
45: }
46:
47: mv.visitCode();
48: Label l0 = new Label();
49: mv.visitLabel(l0);
50: mv.visitLineNumber(591, l0);
51: mv.visitTypeInsn(NEW,
52: "org/apache/wicket/protocol/http/HttpSessionStore");
53: mv.visitInsn(DUP);
54: mv.visitVarInsn(ALOAD, 0);
55: mv.visitMethodInsn(INVOKESPECIAL,
56: "org/apache/wicket/protocol/http/HttpSessionStore",
57: "<init>", "(Lorg/apache/wicket/Application;)V");
58: mv.visitInsn(ARETURN);
59: Label l1 = new Label();
60: mv.visitLabel(l1);
61: mv.visitLocalVariable("this",
62: "Lorg/apache/wicket/protocol/http/WebApplication;",
63: null, l0, l1, 0);
64: mv.visitMaxs(3, 1);
65: mv.visitEnd();
66:
67: return null;
68: }
69:
70: }
|