|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.easybeans.enhancer.CommonClassGenerator
org.objectweb.easybeans.enhancer.interceptors.EasyBeansInvocationContextGenerator
public class EasyBeansInvocationContextGenerator
Generates the implementation of
EasyBeansInvocationContext
interface for a
given business method.
Field Summary | |
---|---|
private java.util.List<JClassInterceptor> |
allInterceptors
List of interceptors. |
static java.lang.String |
ARG
Name of the attributes will start with this name with an index as suffix, ie : arg0, arg1, arg2,... |
private java.lang.String |
beanClassDesc
Bean class descriptor. |
private java.lang.String |
beanClassName
Bean class name. |
private org.objectweb.asm.Type |
beanClassType
Bean class Type (ASM). |
private ClassAnnotationMetadata |
classAnnotationMetadata
Metadata available for a class (extracted from method metadat object. |
private java.lang.String |
constructorDesc
ASM descriptor of the generated constructor. |
static java.lang.String |
EASYBEANS_INVOCATION_CONTEXT
EasyBeansInvocationContext interface. |
private java.lang.String |
generatedClassName
Full class name of the generated class (prefixed by packageName). |
static java.lang.String |
INTERCEPTOR
Name of the interceptor attributes will start with this name with an index as suffix, ie : interceptor0, interceptor1, interceptor2,... |
private InterceptorType |
interceptorType
Type of the interceptor (AroundInvoke, PostConstruct, etc). |
static java.lang.String[] |
INTERFACES
Interface of this invocation context. |
private JMethod |
jMethod
JMethod object which correspond to the current method metadata which is used. |
private static JLog |
logger
Logger. |
private MethodAnnotationMetadata |
methodAnnotationMetadata
Metadata available for a method (given as constructor arg). |
private org.objectweb.asm.Type[] |
methodArgsType
ASM Type arguments of the method. |
static java.lang.String |
PACKAGE_NAME_PREFIX
Prefix used as package name for generated classes (EasyBeansInvocationContext* impl). |
private java.lang.String |
packageName
Package name which is used for generating class. |
static java.lang.String[] |
PROCEED_EXCEPTIONS
Exceptions of the proceed method. |
static java.lang.String |
SUFFIX_CLASS
Suffix for generated classes EasyBeansInvocationContextImpl. |
Fields inherited from class org.objectweb.easybeans.enhancer.CommonClassGenerator |
---|
ARRAY_OBJECTS, EASYBEANS_FACTORY, GENERATED_CLASS_VERSION, JAVA_LANG_EXCEPTION, JAVA_LANG_OBJECT, JAVA_LANG_REFLECT_METHOD, VOID_METHOD_JAVA_LANG_OBJECT |
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, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, 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, 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, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, 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, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6 |
Constructor Summary | |
---|---|
EasyBeansInvocationContextGenerator(MethodAnnotationMetadata methodAnnotationMetadata,
InterceptorType interceptorType)
Constructor It will generate a class for the given method metadata. |
Method Summary | |
---|---|
private void |
addAttributes()
Add attributes of the class in two steps. |
private void |
addClassDeclaration()
Creates the declaration of the class with the given interfaces. |
private void |
addConstructor()
Create the constructor which should look like : First arg = bean instance Last args are arguments of the method (if any) |
private void |
addEasyBeansInvocationContextAttributes()
Adds attributes of EasyBeansInvocationContext interface. |
private void |
addEasyBeansInvocationContextGetFactory()
Adds the getFactory method of EasyBeansInvocationContext interface. It adds : |
private void |
addEasyBeansInvocationContextMethods()
Add methods for EasyBeansInvocationContext interface. |
private void |
addInvocationContextAttributes()
Adds attributes of InvocationContext interface. |
private void |
addInvocationContextGetBean()
Adds the getBean method of InvocationContext interface. It adds : |
void |
addInvocationContextGetContextData()
Adds the getContextData() method. |
private void |
addInvocationContextGetMethod()
Adds the getMethod() method of InvocationContext interface. It adds : |
private void |
addInvocationContextGetParameters()
Adds the getParameters method of InvocationContext interface. It adds : |
private void |
addInvocationContextMethods()
Add methods for InvocationContext interface. |
private void |
addInvocationContextProceed()
Adds the proceed method. It adds : |
private void |
addInvocationContextSetParameters()
Adds the setParameters method of InvocationContext interface. It adds : |
private void |
addMethods()
Add methods of the class in two steps. |
private void |
addStaticClassInitialization()
Adds the initialization of static attributes. |
private void |
addToString()
Generated toString() method. |
private void |
endClass()
Called when the generated class is done. |
void |
generate()
Generates the class. |
byte[] |
getBytes()
|
java.lang.String |
getConstructorDesc()
|
java.lang.String |
getGeneratedClassName()
|
MethodAnnotationMetadata |
getMethodAnnotationMetadata()
|
Methods inherited from class org.objectweb.easybeans.enhancer.CommonClassGenerator |
---|
addAttribute, addAttribute, addReturnType, encodeArrayClassDesc, encodeClassDesc, getCW, putFieldLoadOpCode, returnsObject, transformObjectIntoPrimitive, transformPrimitiveIntoObject, visitClassType |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PACKAGE_NAME_PREFIX
public static final java.lang.String ARG
public static final java.lang.String INTERCEPTOR
public static final java.lang.String SUFFIX_CLASS
public static final java.lang.String[] INTERFACES
public static final java.lang.String[] PROCEED_EXCEPTIONS
public static final java.lang.String EASYBEANS_INVOCATION_CONTEXT
private static JLog logger
private ClassAnnotationMetadata classAnnotationMetadata
private java.lang.String packageName
private java.lang.String generatedClassName
private JMethod jMethod
private MethodAnnotationMetadata methodAnnotationMetadata
private java.lang.String beanClassDesc
private java.lang.String beanClassName
private org.objectweb.asm.Type beanClassType
private java.lang.String constructorDesc
private org.objectweb.asm.Type[] methodArgsType
private java.util.List<JClassInterceptor> allInterceptors
private InterceptorType interceptorType
Constructor Detail |
---|
public EasyBeansInvocationContextGenerator(MethodAnnotationMetadata methodAnnotationMetadata, InterceptorType interceptorType)
methodAnnotationMetadata
- method meta datainterceptorType
- the type of invocationContext to generate (AroundInvoke, PostConstruct, etc)Method Detail |
---|
public void generate()
public byte[] getBytes()
private void addClassDeclaration()
private void addConstructor()
public CtxImpl(Bean bean, int i, Long k, ...) { this.bean = bean; this.i = i; this.k = k; this... = ... }
private void endClass()
private void addAttributes()
private void addMethods()
private void addInvocationContextMethods()
private void addEasyBeansInvocationContextMethods()
private void addInvocationContextGetBean()
public Object getBean() { return bean; }
private void addEasyBeansInvocationContextGetFactory()
public Factory getFactory() { return this.factory; }
private void addInvocationContextGetMethod()
public Method getMethod() { if (method == null) { try { method = MyEjb.class.getMethod("methodName", new Class[] {xxx, yyy, ...}); } catch (SecurityException e) { throw new RuntimeException("Cannot...", e); } catch (NoSuchMethodException e) { throw new RuntimeException("Cannot...", e); } } return method; }
private void addInvocationContextAttributes()
private StatelessBean bean; private Object[] parameters; private static Method method; private int interceptor; private Map contextData; // args of the method private TYPE_ARG_METHOD arg0 = xxx; private TYPE_ARG_METHOD arg1 = xxx; private TYPE_ARG_METHOD arg2 = xxx; private TYPE_ARG_METHOD.......;
private void addStaticClassInitialization()
private void addEasyBeansInvocationContextAttributes()
private Factory factory;
private void addInvocationContextProceed()
public Object proceed() throws Exception { interceptor++; switch (interceptor) { case 1 : return myInterceptor.intercept(this); case 2 : return otherInterceptor.intercept(this); case 3 : return bean.originalmethod(...); default: throw new IllegalStateException("Problem in interceptors"); } }
public void addInvocationContextGetContextData()
public Map getContextData() { if (contextData == null) { contextData = new HashMap(); } return contextData; }
private void addInvocationContextGetParameters()
public Object[] getParameters() { if (parameters == null) { parameters = new Object[] {arg0, arg1, argxxx}; } return parameters; }
private void addInvocationContextSetParameters()
public void setParameters(Object[] parameters) { this.parameters = parameters; }
private void addToString()
public MethodAnnotationMetadata getMethodAnnotationMetadata()
public java.lang.String getGeneratedClassName()
public java.lang.String getConstructorDesc()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |