org.apache.aries.proxy.impl.common
Class AbstractWovenProxyAdapter

java.lang.Object
  extended by org.objectweb.asm.ClassVisitor
      extended by org.apache.aries.proxy.impl.common.AbstractWovenProxyAdapter
All Implemented Interfaces:
org.objectweb.asm.Opcodes

public abstract class AbstractWovenProxyAdapter
extends org.objectweb.asm.ClassVisitor
implements org.objectweb.asm.Opcodes

This abstract superclass is responsible for providing proxy extensions to classes being written. Classes processed by this adapter will implement WovenProxy, and have a static initialiser that populates Method fields for use with the InvocationListener. Known subclasses are WovenProxyAdapter, used to weave classes being loaded by the framework, and InterfaceCombiningClassAdapter which is used to dynamically create objects that implement multiple interfaces


Field Summary
protected  org.objectweb.asm.Type currentMethodDeclaringType
           
protected  boolean currentMethodDeclaringTypeIsInterface
           
static String DISPATCHER_FIELD
          the name of the field used to store the dispatcher
static org.objectweb.asm.Type DISPATCHER_TYPE
          The ASM type for the dispatcher
static boolean IS_AT_LEAST_JAVA_6
           
protected  boolean isSerializable
          If we have a no-args constructor then we can delegate there rather than to a super no-args
protected static String LISTENER_FIELD
          the name of the field used to store the InvocationListener
protected  List<Class<?>> nonObjectSupers
          A list of un-woven superclasses between this object and Object, only populated for classes which will directly implement WovenProxy.
static org.objectweb.asm.Type OBJECT_TYPE
           
protected  Map<String,TypeMethod> transformedMethods
          Methods we have transformed and need to create static fields for.
protected  org.objectweb.asm.Type typeBeingWoven
          The type of this class
 
Fields inherited from class org.objectweb.asm.ClassVisitor
api, cv
 
Fields inherited from interface org.objectweb.asm.Opcodes
AALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASM4, ASTORE, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DMUL, DNEG, DOUBLE, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F_APPEND, F_CHOP, F_FULL, F_NEW, F_SAME, F_SAME1, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FLOAT, FMUL, FNEG, FREM, FRETURN, FSTORE, FSUB, GETFIELD, GETSTATIC, GOTO, H_GETFIELD, H_GETSTATIC, H_INVOKEINTERFACE, H_INVOKESPECIAL, H_INVOKESTATIC, H_INVOKEVIRTUAL, H_NEWINVOKESPECIAL, H_PUTFIELD, H_PUTSTATIC, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, IMUL, INEG, INSTANCEOF, INTEGER, INVOKEDYNAMIC, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISUB, IUSHR, IXOR, JSR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDIV, LLOAD, LMUL, LNEG, LONG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, NULL, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, TOP, UNINITIALIZED_THIS, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7
 
Constructor Summary
AbstractWovenProxyAdapter(org.objectweb.asm.ClassVisitor writer, String className, ClassLoader loader)
          Create a new adapter for the supplied class
 
Method Summary
 Set<org.objectweb.asm.commons.Method> getKnownMethods()
           
static String getSanitizedUUIDString()
          Get a new UUID suitable for use in method and field names
protected abstract  org.objectweb.asm.MethodVisitor getWeavingMethodVisitor(int access, String name, String desc, String signature, String[] exceptions, org.objectweb.asm.commons.Method currentMethod, String methodStaticFieldName, org.objectweb.asm.Type currentMethodDeclaringType, boolean currentMethodDeclaringTypeIsInterface)
          Get the MethodVisitor that will weave a given method
static void readClass(Class<?> c, org.objectweb.asm.ClassVisitor adapter)
          This method will read the bytes for the supplied Class using the supplied ASM ClassVisitor, the reader will skip DEBUG, FRAMES and CODE.
 void setCurrentMethodDeclaringType(org.objectweb.asm.Type type, boolean isInterface)
           
 void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
           
 void visitEnd()
          Our class may claim to implement WovenProxy, but doesn't have any implementations! We should fix this.
 org.objectweb.asm.MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
          This method is called on each method implemented on this object (but not for superclass methods) Each of these methods is visited in turn and the code here generates the byte code for the calls to the InovcationListener around the existing method
 
Methods inherited from class org.objectweb.asm.ClassVisitor
visitAnnotation, visitAttribute, visitField, visitInnerClass, visitOuterClass, visitSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LISTENER_FIELD

protected static final String LISTENER_FIELD
the name of the field used to store the InvocationListener


DISPATCHER_FIELD

public static final String DISPATCHER_FIELD
the name of the field used to store the dispatcher


DISPATCHER_TYPE

public static final org.objectweb.asm.Type DISPATCHER_TYPE
The ASM type for the dispatcher


OBJECT_TYPE

public static final org.objectweb.asm.Type OBJECT_TYPE

typeBeingWoven

protected final org.objectweb.asm.Type typeBeingWoven
The type of this class


nonObjectSupers

protected final List<Class<?>> nonObjectSupers
A list of un-woven superclasses between this object and Object, only populated for classes which will directly implement WovenProxy. This list is then used to override any methods that would otherwise be missed by the weaving process.


transformedMethods

protected final Map<String,TypeMethod> transformedMethods
Methods we have transformed and need to create static fields for. Stored as field name to TypeMethod so we know which Class to reflect them off


isSerializable

protected boolean isSerializable
If we have a no-args constructor then we can delegate there rather than to a super no-args


currentMethodDeclaringType

protected org.objectweb.asm.Type currentMethodDeclaringType

currentMethodDeclaringTypeIsInterface

protected boolean currentMethodDeclaringTypeIsInterface

IS_AT_LEAST_JAVA_6

public static final boolean IS_AT_LEAST_JAVA_6
Constructor Detail

AbstractWovenProxyAdapter

public AbstractWovenProxyAdapter(org.objectweb.asm.ClassVisitor writer,
                                 String className,
                                 ClassLoader loader)
Create a new adapter for the supplied class

Parameters:
writer - The ClassWriter to delegate to
className - The name of this class
loader - The ClassLoader loading this class
Method Detail

visit

public final void visit(int version,
                        int access,
                        String name,
                        String signature,
                        String superName,
                        String[] interfaces)
Overrides:
visit in class org.objectweb.asm.ClassVisitor

visitMethod

public final org.objectweb.asm.MethodVisitor visitMethod(int access,
                                                         String name,
                                                         String desc,
                                                         String signature,
                                                         String[] exceptions)
This method is called on each method implemented on this object (but not for superclass methods) Each of these methods is visited in turn and the code here generates the byte code for the calls to the InovcationListener around the existing method

Overrides:
visitMethod in class org.objectweb.asm.ClassVisitor

visitEnd

public void visitEnd()
Our class may claim to implement WovenProxy, but doesn't have any implementations! We should fix this.

Overrides:
visitEnd in class org.objectweb.asm.ClassVisitor

getKnownMethods

public Set<org.objectweb.asm.commons.Method> getKnownMethods()

getWeavingMethodVisitor

protected abstract org.objectweb.asm.MethodVisitor getWeavingMethodVisitor(int access,
                                                                           String name,
                                                                           String desc,
                                                                           String signature,
                                                                           String[] exceptions,
                                                                           org.objectweb.asm.commons.Method currentMethod,
                                                                           String methodStaticFieldName,
                                                                           org.objectweb.asm.Type currentMethodDeclaringType,
                                                                           boolean currentMethodDeclaringTypeIsInterface)
Get the MethodVisitor that will weave a given method

Parameters:
access -
name -
desc -
signature -
exceptions -
currentMethod -
methodStaticFieldName -
Returns:

getSanitizedUUIDString

public static final String getSanitizedUUIDString()
Get a new UUID suitable for use in method and field names

Returns:

readClass

public static void readClass(Class<?> c,
                             org.objectweb.asm.ClassVisitor adapter)
                      throws IOException
This method will read the bytes for the supplied Class using the supplied ASM ClassVisitor, the reader will skip DEBUG, FRAMES and CODE.

Parameters:
c -
adapter -
Throws:
IOException

setCurrentMethodDeclaringType

public final void setCurrentMethodDeclaringType(org.objectweb.asm.Type type,
                                                boolean isInterface)


Copyright © 2009-2012 The Apache Software Foundation. All Rights Reserved.