|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.asm.ClassAdapter
org.objectweb.easybeans.enhancer.interceptors.InterceptorClassAdapter
public class InterceptorClassAdapter
This class delegates the creation of an implementation of a EasyBeansInvocationContext interface and intercepts all business methods() of a Bean.
Field Summary | |
---|---|
private boolean |
addInterface
If it is true, interfaces of interceptor lifecycle will be added. |
private java.util.List<java.lang.String> |
beanInterceptors
List of interceptors classes used by the bean. |
private ClassAnnotationMetadata |
classAnnotationMetadata
Metadata available by this adapter for a class. |
private java.util.List<DefinedClass> |
definedClasses
Mappping between className and the bytecode. |
private java.util.List<InterceptorType> |
generatedTypes
List of generated classes for each interceptor type. |
private java.util.List<JMethod> |
renamedMethods
List of methods which have been renamed. |
Fields inherited from class org.objectweb.asm.ClassAdapter |
---|
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, 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, 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, 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 |
Constructor Summary | |
---|---|
InterceptorClassAdapter(ClassAnnotationMetadata classAnnotationMetadata,
org.objectweb.asm.ClassVisitor cv)
Constructor. |
|
InterceptorClassAdapter(ClassAnnotationMetadata classAnnotationMetadata,
org.objectweb.asm.ClassVisitor cv,
boolean addInterface)
Constructor. |
Method Summary | |
---|---|
private MethodAnnotationMetadata |
generateBeanLifeCycleMethod(ClassAnnotationMetadata classMetaData,
InterceptorType interceptorType)
Generates a default method for lifecycle method events. |
private void |
generateCallSuperEncodedMethod(MethodAnnotationMetadata method)
Generates a call to the method defined in the super class. |
private void |
generateCallToInvocationContext(MethodAnnotationMetadata method,
EasyBeansInvocationContextGenerator genInvCtx,
InterceptorType interceptorType)
Generates the call to InvocationContext impl proceed method after building a new object. |
private void |
generateClass(MethodAnnotationMetadata method,
InterceptorType interceptorType)
Generate an invocation context object. |
java.util.List<DefinedClass> |
getDefinedClasses()
|
private boolean |
isDependencyInjectionMethod(JMethod jMethod)
Check if this method is the injected method used for dependency injection. |
private boolean |
isInjectedMethod(JMethod jMethod)
Check if this method is injected or not by injection class adapter : No need to add interceptors on these methods. |
private boolean |
isInterceptedMethod(JMethod jMethod)
|
private boolean |
isInterceptorMethod(JMethod jMethod)
|
void |
visit(int version,
int access,
java.lang.String name,
java.lang.String signature,
java.lang.String superName,
java.lang.String[] interfaces)
Visits the header of the class. |
void |
visitEnd()
Visits the end of the class. |
void |
visitInnerClass(java.lang.String name,
java.lang.String outerName,
java.lang.String innerName,
int access)
Visits information about an inner class. |
org.objectweb.asm.MethodVisitor |
visitMethod(int access,
java.lang.String name,
java.lang.String desc,
java.lang.String signature,
java.lang.String[] exceptions)
Visits a method of the class. |
Methods inherited from class org.objectweb.asm.ClassAdapter |
---|
visitAnnotation, visitAttribute, visitField, visitOuterClass, visitSource |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private ClassAnnotationMetadata classAnnotationMetadata
private java.util.List<JMethod> renamedMethods
private java.util.List<DefinedClass> definedClasses
private java.util.List<InterceptorType> generatedTypes
private java.util.List<java.lang.String> beanInterceptors
private boolean addInterface
Constructor Detail |
---|
public InterceptorClassAdapter(ClassAnnotationMetadata classAnnotationMetadata, org.objectweb.asm.ClassVisitor cv)
classAnnotationMetadata
- object containing all attributes of the
classcv
- the class visitor to which this adapter must delegate calls.public InterceptorClassAdapter(ClassAnnotationMetadata classAnnotationMetadata, org.objectweb.asm.ClassVisitor cv, boolean addInterface)
classAnnotationMetadata
- object containing all attributes of the
classcv
- the class visitor to which this adapter must delegate calls.addInterface
- adds lifecycle interface for a given bean.Method Detail |
---|
public void visit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String superName, java.lang.String[] interfaces)
visit
in interface org.objectweb.asm.ClassVisitor
visit
in class org.objectweb.asm.ClassAdapter
version
- the class version.access
- the class's access flags (see
Opcodes
). This parameter also indicates
if the class is deprecated.name
- the internal name of the class (see
getInternalName
).signature
- the signature of this class. May be null if
the class is not a generic one, and does not extend or implement
generic classes or interfaces.superName
- the internal of name of the super class (see
getInternalName
).
For interfaces, the super class is Object
. May be
null, but only for the Object
class.interfaces
- the internal names of the class's interfaces (see
getInternalName
).
May be null.public void visitInnerClass(java.lang.String name, java.lang.String outerName, java.lang.String innerName, int access)
visitInnerClass
in interface org.objectweb.asm.ClassVisitor
visitInnerClass
in class org.objectweb.asm.ClassAdapter
name
- the internal name of an inner class (see
getInternalName
).outerName
- the internal name of the class to which the inner class
belongs (see
getInternalName
).
May be null.innerName
- the (simple) name of the inner class inside its
enclosing class. May be null for anonymous inner
classes.access
- the access flags of the inner class as originally declared
in the enclosing class.public org.objectweb.asm.MethodVisitor visitMethod(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)
visitMethod
in interface org.objectweb.asm.ClassVisitor
visitMethod
in class org.objectweb.asm.ClassAdapter
access
- the method's access flags (see Opcodes
). This
parameter also indicates if the method is synthetic and/or
deprecated.name
- the method's name.desc
- the method's descriptor (see Type
).signature
- the method's signature. May be null if the
method parameters, return type and exceptions do not use generic
types.exceptions
- the internal names of the method's exception classes
(see
getInternalName
).
May be null.
public void visitEnd()
visitEnd
in interface org.objectweb.asm.ClassVisitor
visitEnd
in class org.objectweb.asm.ClassAdapter
private void generateCallToInvocationContext(MethodAnnotationMetadata method, EasyBeansInvocationContextGenerator genInvCtx, InterceptorType interceptorType)
public int generatedMethodName(int a, int b) throws MyException { try { return ((Integer) new MethodAddInvocationContextImpl(this, a, b).proceed()).intValue(); } catch (MyException e) { throw e; } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { throw new RuntimeException(e); } } }
method
- the annotation metadata of the methodgenInvCtx
- the generator of the EasyBeansInvocationContext impl class.interceptorType
- the type of method which is interceptedprivate void generateClass(MethodAnnotationMetadata method, InterceptorType interceptorType)
method
- intercepted methodinterceptorType
- the type of method which is interceptedprivate void generateCallSuperEncodedMethod(MethodAnnotationMetadata method)
method
- the annotation metadata of the methodprivate MethodAnnotationMetadata generateBeanLifeCycleMethod(ClassAnnotationMetadata classMetaData, InterceptorType interceptorType)
classMetaData
- the metadata used to generate method metadatainterceptorType
- the type of intercepted method
private boolean isDependencyInjectionMethod(JMethod jMethod)
jMethod
- object to check
private boolean isInjectedMethod(JMethod jMethod)
jMethod
- object to check
private boolean isInterceptedMethod(JMethod jMethod)
jMethod
- object to check
private boolean isInterceptorMethod(JMethod jMethod)
jMethod
- object to check
public java.util.List<DefinedClass> getDefinedClasses()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |