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.ClassAdapterFactory;
12:
13: public class JarClassLoaderAdapter extends ClassAdapter implements
14: ClassAdapterFactory, Opcodes {
15:
16: public JarClassLoaderAdapter(ClassVisitor cv) {
17: super (cv);
18: }
19:
20: public JarClassLoaderAdapter() {
21: super (null);
22: }
23:
24: public ClassAdapter create(ClassVisitor visitor, ClassLoader loader) {
25: return new JarClassLoaderAdapter(visitor);
26: }
27:
28: public void visitEnd() {
29: // delegate NamedClassLoader methods to the delegate loader in our parent class
30:
31: MethodVisitor mv = super .visitMethod(ACC_PUBLIC,
32: "__tc_getClassLoaderName", "()Ljava/lang/String;",
33: null, null);
34: mv.visitCode();
35: mv.visitVarInsn(ALOAD, 0);
36: mv.visitMethodInsn(INVOKEVIRTUAL,
37: "com/ibm/ws/classloader/JarClassLoader",
38: "getCurrentClassLoader",
39: "()Lcom/ibm/ws/classloader/CompoundClassLoader;");
40: mv.visitTypeInsn(CHECKCAST,
41: "com/tc/object/loaders/NamedClassLoader");
42: mv.visitMethodInsn(INVOKEINTERFACE,
43: "com/tc/object/loaders/NamedClassLoader",
44: "__tc_getClassLoaderName", "()Ljava/lang/String;");
45: mv.visitInsn(ARETURN);
46: mv.visitMaxs(0, 0);
47: mv.visitEnd();
48:
49: mv = super .visitMethod(ACC_PUBLIC, "__tc_setClassLoaderName",
50: "(Ljava/lang/String;)V", null, null);
51: mv.visitCode();
52: mv.visitVarInsn(ALOAD, 0);
53: mv.visitMethodInsn(INVOKEVIRTUAL,
54: "com/ibm/ws/classloader/JarClassLoader",
55: "getCurrentClassLoader",
56: "()Lcom/ibm/ws/classloader/CompoundClassLoader;");
57: mv.visitTypeInsn(CHECKCAST,
58: "com/tc/object/loaders/NamedClassLoader");
59: mv.visitVarInsn(ALOAD, 1);
60: mv.visitMethodInsn(INVOKEINTERFACE,
61: "com/tc/object/loaders/NamedClassLoader",
62: "__tc_setClassLoaderName", "(Ljava/lang/String;)V");
63: mv.visitInsn(RETURN);
64: mv.visitMaxs(0, 0);
65: mv.visitEnd();
66:
67: super.visitEnd();
68: }
69: }
|