1 25 26 package org.objectweb.easybeans.enhancer.client; 27 28 import org.objectweb.asm.ClassAdapter; 29 import org.objectweb.asm.ClassVisitor; 30 import org.objectweb.asm.MethodVisitor; 31 import org.objectweb.asm.Opcodes; 32 import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata; 33 import org.objectweb.easybeans.deployment.annotations.metadata.EjbJarAnnotationMetadata; 34 import org.objectweb.easybeans.deployment.annotations.metadata.MethodAnnotationMetadata; 35 36 41 public class ClientLifeCycleAdapter extends ClassAdapter implements Opcodes { 42 43 46 private ClassAnnotationMetadata classAnnotationMetadata; 47 48 51 public static final String JAVA_LANG_OBJECT = "java/lang/Object"; 52 53 59 public ClientLifeCycleAdapter(final ClassAnnotationMetadata classAnnotationMetadata, final ClassVisitor cv) { 60 super(cv); 61 this.classAnnotationMetadata = classAnnotationMetadata; 62 } 63 64 69 @Override 70 public void visitEnd() { 71 super.visitEnd(); 72 73 MethodVisitor mv = cv 75 .visitMethod(ACC_PUBLIC + ACC_STATIC, "easyBeansLifeCyclePostConstruct", "()V", null, null); 76 mv.visitCode(); 77 78 String superNameClass = classAnnotationMetadata.getSuperName(); 80 if (superNameClass != null && !superNameClass.equals(JAVA_LANG_OBJECT)) { 81 EjbJarAnnotationMetadata jarMetadata = classAnnotationMetadata.getEjbJarAnnotationMetadata(); 82 ClassAnnotationMetadata superMetadata = jarMetadata.getClassAnnotationMetadata(superNameClass); 83 if (superMetadata != null) { 84 mv.visitMethodInsn(INVOKESTATIC, superMetadata.getClassName(), "easyBeansLifeCyclePostConstruct", "()V"); 85 } 86 } 87 88 for (MethodAnnotationMetadata method : classAnnotationMetadata.getPostConstructMethodsMetadata()) { 90 String clName = method.getClassAnnotationMetadata().getClassName(); 91 mv.visitMethodInsn(INVOKESTATIC, clName, method.getMethodName(), method.getJMethod().getDescriptor()); 92 } 93 94 mv.visitInsn(RETURN); 95 mv.visitMaxs(0, 0); 96 mv.visitEnd(); 97 } 98 99 } 100 | Popular Tags |