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.websphere_6_1;
06:
07: import com.tc.asm.ClassAdapter;
08: import com.tc.asm.ClassVisitor;
09: import com.tc.asm.MethodVisitor;
10: import com.tc.asm.Opcodes;
11: import com.tc.object.bytecode.ByteCodeUtil;
12: import com.tc.object.bytecode.ClassAdapterFactory;
13:
14: public class ServletContextFacadeAdapater extends ClassAdapter
15: implements ClassAdapterFactory, Opcodes {
16:
17: public ServletContextFacadeAdapater(ClassVisitor cv) {
18: super (cv);
19: }
20:
21: public ServletContextFacadeAdapater() {
22: super (null);
23: }
24:
25: public ClassAdapter create(ClassVisitor visitor, ClassLoader loader) {
26: return new ServletContextFacadeAdapater(visitor);
27: }
28:
29: public void visitEnd() {
30: // add a method to let us get the session context
31: MethodVisitor mv = super .visitMethod(ACC_PUBLIC,
32: ByteCodeUtil.TC_METHOD_PREFIX + "getSessionContext",
33: "()Ljava/lang/Object;", null, null);
34: mv.visitCode();
35: mv.visitVarInsn(ALOAD, 0);
36: mv.visitFieldInsn(GETFIELD,
37: "com/ibm/ws/webcontainer/facade/ServletContextFacade",
38: "context",
39: "Lcom/ibm/wsspi/webcontainer/servlet/IServletContext;");
40: mv.visitTypeInsn(CHECKCAST,
41: "com/ibm/ws/webcontainer/webapp/WebApp");
42: mv
43: .visitMethodInsn(INVOKEVIRTUAL,
44: "com/ibm/ws/webcontainer/webapp/WebApp",
45: "getSessionContext",
46: "()Lcom/ibm/ws/webcontainer/session/IHttpSessionContext;");
47: mv.visitInsn(ARETURN);
48: mv.visitMaxs(0, 0);
49: mv.visitEnd();
50:
51: super.visitEnd();
52: }
53:
54: }
|