1 25 26 package org.objectweb.easybeans.deployment.annotations.helper.bean; 27 28 import org.objectweb.easybeans.deployment.annotations.JMethod; 29 import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata; 30 import org.objectweb.easybeans.deployment.annotations.metadata.MethodAnnotationMetadata; 31 import org.objectweb.easybeans.log.JLog; 32 import org.objectweb.easybeans.log.JLogFactory; 33 34 39 public final class BusinessMethodResolver { 40 41 45 private static final String CLASS_INIT = "<clinit>"; 46 47 51 private static final String CONST_INIT = "<init>"; 52 53 56 private static JLog logger = JLogFactory.getLog(BusinessMethodResolver.class); 57 58 61 private BusinessMethodResolver() { 62 63 } 64 65 70 public static void resolve(final ClassAnnotationMetadata classAnnotationMetadata) { 71 loop(classAnnotationMetadata, classAnnotationMetadata); 72 } 73 74 80 private static void loop(final ClassAnnotationMetadata beanclassAnnotationMetadata, 81 final ClassAnnotationMetadata visitingclassAnnotationMetadata) { 82 85 for (String itf : visitingclassAnnotationMetadata.getInterfaces()) { 86 if (itf.startsWith("javax/ejb/") || itf.startsWith("java/io/Serializable") 87 || itf.startsWith("java/io/Externalizable")) { 88 continue; 89 } 90 91 ClassAnnotationMetadata itfMetadata = visitingclassAnnotationMetadata.getEjbJarAnnotationMetadata() 93 .getClassAnnotationMetadata(itf); 94 95 if (itfMetadata == null) { 96 logger.warn("No class was found for interface {0}.", itf); 97 continue; 98 } 99 100 for (MethodAnnotationMetadata methodData : itfMetadata.getMethodAnnotationMetadataCollection()) { 103 JMethod itfMethod = methodData.getJMethod(); 104 105 if (itfMethod.getName().equals(CLASS_INIT) || itfMethod.getName().equals(CONST_INIT)) { 107 continue; 108 } 109 110 MethodAnnotationMetadata beanMethod = beanclassAnnotationMetadata.getMethodAnnotationMetadata(itfMethod); 112 if (beanMethod == null) { 113 throw new IllegalStateException ("No method was found for method " + itfMethod + " in class " 115 + beanclassAnnotationMetadata.getClassName()); 116 } 117 beanMethod.setBusinessMethod(true); 118 } 119 120 if (itfMetadata.getInterfaces() != null) { 122 loop(beanclassAnnotationMetadata, itfMetadata); 123 } 124 } 125 } 126 127 } 128 | Popular Tags |