1 25 26 package org.objectweb.easybeans.deployment.annotations.helper.bean; 27 28 import java.util.ArrayList ; 29 import java.util.List ; 30 31 import org.objectweb.easybeans.deployment.annotations.exceptions.ResolverException; 32 import org.objectweb.easybeans.deployment.annotations.impl.JLocal; 33 import org.objectweb.easybeans.deployment.annotations.impl.JRemote; 34 import org.objectweb.easybeans.deployment.annotations.metadata.ClassAnnotationMetadata; 35 import org.objectweb.easybeans.deployment.annotations.metadata.EjbJarAnnotationMetadata; 36 37 42 public final class InheritanceInterfacesHelper { 43 44 47 public static final String JAVA_LANG_OBJECT = "java/lang/Object"; 48 49 52 private InheritanceInterfacesHelper() { 53 54 } 55 56 62 public static void resolve(final ClassAnnotationMetadata classAnnotationMetadata) throws ResolverException { 63 loop(classAnnotationMetadata, classAnnotationMetadata); 64 65 } 66 67 73 public static void loop(final ClassAnnotationMetadata beanClassAnnotationMetadata, 74 final ClassAnnotationMetadata visitingClassAnnotationMetadata) throws ResolverException { 75 String superClass = visitingClassAnnotationMetadata.getSuperName(); 76 if (superClass != null) { 77 if (!superClass.equals(JAVA_LANG_OBJECT)) { 79 EjbJarAnnotationMetadata ejbJarAnnotationMetadata = beanClassAnnotationMetadata 80 .getEjbJarAnnotationMetadata(); 81 ClassAnnotationMetadata superMetadata = ejbJarAnnotationMetadata.getClassAnnotationMetadata(superClass); 82 83 if (superMetadata == null) { 84 throw new IllegalStateException ("No super class named '" + superClass 85 + "' was analyzed. But it is referenced from '" + visitingClassAnnotationMetadata.getClassName() 86 + "'."); 87 } 88 89 List <String > newInterfacesLst = new ArrayList <String >(); 91 String [] currentInterfaces = beanClassAnnotationMetadata.getInterfaces(); 92 if (currentInterfaces != null) { 93 for (String itf : currentInterfaces) { 94 newInterfacesLst.add(itf); 95 } 96 } 97 98 String [] superInterfaces = superMetadata.getInterfaces(); 101 if (superInterfaces != null) { 102 for (String itf : superInterfaces) { 103 if (!newInterfacesLst.contains(itf)) { 104 newInterfacesLst.add(itf); 105 } 106 } 107 } 108 109 beanClassAnnotationMetadata.setInterfaces(newInterfacesLst.toArray(new String [newInterfacesLst.size()])); 111 112 JLocal currentLocalInterfaces = beanClassAnnotationMetadata.getLocalInterfaces(); 115 JLocal superLocalInterfaces = superMetadata.getLocalInterfaces(); 116 if (superLocalInterfaces != null) { 117 if (currentLocalInterfaces == null) { 118 currentLocalInterfaces = new JLocal(); 119 beanClassAnnotationMetadata.setLocalInterfaces(currentLocalInterfaces); 120 } 121 for (String itf : superLocalInterfaces.getInterfaces()) { 122 if (!currentLocalInterfaces.getInterfaces().contains(itf)) { 123 currentLocalInterfaces.addInterface(itf); 124 } 125 } 126 } 127 128 JRemote currentRemoteInterfaces = beanClassAnnotationMetadata.getRemoteInterfaces(); 130 JRemote superRemoteInterfaces = superMetadata.getRemoteInterfaces(); 131 if (superRemoteInterfaces != null) { 132 if (currentRemoteInterfaces == null) { 133 currentRemoteInterfaces = new JRemote(); 134 beanClassAnnotationMetadata.setRemoteInterfaces(currentRemoteInterfaces); 135 } 136 for (String itf : superRemoteInterfaces.getInterfaces()) { 137 if (!currentRemoteInterfaces.getInterfaces().contains(itf)) { 138 currentRemoteInterfaces.addInterface(itf); 139 } 140 } 141 } 142 143 if (!superMetadata.getClassName().equals(JAVA_LANG_OBJECT)) { 145 loop(beanClassAnnotationMetadata, superMetadata); 146 } 147 } 148 } 149 } 150 } 151 | Popular Tags |