1 25 26 package org.objectweb.easybeans.deployment.annotations.helper.bean; 27 28 import org.objectweb.asm.Type; 29 30 import org.objectweb.easybeans.deployment.annotations.JMethod; 31 import org.objectweb.easybeans.deployment.annotations.exceptions.ResolverException; 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 45 public final class InheritanceMethodResolver { 46 47 50 private static final String JAVA_LANG_OBJECT = Type.getInternalName(Object .class); 51 52 55 private InheritanceMethodResolver() { 56 57 } 58 59 65 public static void resolve(final ClassAnnotationMetadata classAnnotationMetadata) throws ResolverException { 66 addMethodMetadata(classAnnotationMetadata, classAnnotationMetadata); 67 } 68 69 78 private static void addMethodMetadata(final ClassAnnotationMetadata beanclassAnnotationMetadata, 79 final ClassAnnotationMetadata visitingClassAnnotationMetadata) throws ResolverException { 80 81 String superClass = visitingClassAnnotationMetadata.getSuperName(); 83 84 if (superClass != null) { 85 86 if (superClass.equals(JAVA_LANG_OBJECT)) { 88 return; 89 } 90 91 EjbJarAnnotationMetadata ejbJarAnnotationMetadata = beanclassAnnotationMetadata.getEjbJarAnnotationMetadata(); 93 94 ClassAnnotationMetadata superClassMetadata = ejbJarAnnotationMetadata.getClassAnnotationMetadata(superClass); 96 97 if (superClassMetadata == null) { 98 throw new ResolverException("The class " + beanclassAnnotationMetadata + " extends the class " + superClass 100 + "but this class seems to be outside of the ejb-jar"); 101 } 102 103 for (MethodAnnotationMetadata methodAnnotationMetadata : superClassMetadata.getMethodAnnotationMetadataCollection()) { 107 JMethod method = methodAnnotationMetadata.getJMethod(); 109 110 if (beanclassAnnotationMetadata 112 .getMethodAnnotationMetadata(method) == null) { 113 MethodAnnotationMetadata clonedMethodAnnotationMetadata = (MethodAnnotationMetadata) methodAnnotationMetadata 115 .clone(); 116 clonedMethodAnnotationMetadata 118 .setClassAnnotationMetadata(beanclassAnnotationMetadata); 119 beanclassAnnotationMetadata 120 .addMethodAnnotationMetadata(clonedMethodAnnotationMetadata); 121 122 clonedMethodAnnotationMetadata.setInherited(true, superClassMetadata); 124 125 if (clonedMethodAnnotationMetadata.isPostConstruct()) { 127 beanclassAnnotationMetadata.addPostConstructMethodMetadata(clonedMethodAnnotationMetadata); 128 } 129 if (clonedMethodAnnotationMetadata.isPreDestroy()) { 130 beanclassAnnotationMetadata.addPreDestroyMethodMetadata(clonedMethodAnnotationMetadata); 131 } 132 if (clonedMethodAnnotationMetadata.isPostActivate()) { 133 beanclassAnnotationMetadata.addPostActivateMethodMetadata(clonedMethodAnnotationMetadata); 134 } 135 if (clonedMethodAnnotationMetadata.isPrePassivate()) { 136 beanclassAnnotationMetadata.addPrePassivateMethodMetadata(clonedMethodAnnotationMetadata); 137 } 138 if (clonedMethodAnnotationMetadata.isAroundInvoke()) { 139 beanclassAnnotationMetadata.addAroundInvokeMethodMetadata(clonedMethodAnnotationMetadata); 140 } 141 } 142 } 143 144 addMethodMetadata(beanclassAnnotationMetadata, superClassMetadata); 146 147 } 148 } 149 150 } 151 | Popular Tags |