1 25 26 package org.objectweb.easybeans.deployment.annotations.metadata; 27 28 import java.util.Collection ; 29 import java.util.HashMap ; 30 import java.util.Map ; 31 32 import javax.ejb.ApplicationException ; 33 34 import org.objectweb.easybeans.deployment.annotations.impl.JApplicationException; 35 import org.objectweb.easybeans.deployment.xml.struct.EJB3; 36 import org.objectweb.easybeans.log.JLog; 37 import org.objectweb.easybeans.log.JLogFactory; 38 39 44 public class EjbJarAnnotationMetadata { 45 46 49 private static JLog logger = JLogFactory.getLog(EjbJarAnnotationMetadata.class); 50 51 54 private Map <String , ClassAnnotationMetadata> classesAnnotationMetadata = null; 55 56 59 private EJB3 ejb3 = null; 60 61 64 private Map <String , ApplicationException > applicationExceptions = null; 65 66 69 public EjbJarAnnotationMetadata() { 70 classesAnnotationMetadata = new HashMap <String , ClassAnnotationMetadata>(); 71 } 72 73 77 public void addClassAnnotationMetadata(final ClassAnnotationMetadata classAnnotationMetadata) { 78 String key = classAnnotationMetadata.getClassName(); 79 if (classesAnnotationMetadata.containsKey(key)) { 81 String msg = logger.getI18n().getMessage("EjbJarAnnotationMetadata.addClassAnnotationMetadata.alreadyPresent", key); 82 logger.debug(msg); 83 throw new IllegalStateException (msg); 84 } 85 classesAnnotationMetadata.put(key, classAnnotationMetadata); 86 } 87 88 89 94 public ClassAnnotationMetadata getClassAnnotationMetadata(final String className) { 95 return classesAnnotationMetadata.get(className); 96 } 97 98 102 public Collection <ClassAnnotationMetadata> getClassAnnotationMetadataCollection() { 103 return classesAnnotationMetadata.values(); 104 } 105 106 109 public EJB3 getEjb3() { 110 return ejb3; 111 } 112 113 117 public void setEjb3(final EJB3 ejb3) { 118 this.ejb3 = ejb3; 119 } 120 121 125 public Map <String , ApplicationException > getApplicationExceptions() { 126 if (applicationExceptions != null) { 127 return applicationExceptions; 128 } 129 130 applicationExceptions = new HashMap <String , ApplicationException >(); 132 133 for (ClassAnnotationMetadata classMetadata : getClassAnnotationMetadataCollection()) { 135 ApplicationException appException = classMetadata.getApplicationException(); 136 if (appException != null) { 138 applicationExceptions.put(classMetadata.getClassName().replaceAll("/", "."), appException); 139 } 140 } 141 142 applicationExceptions.put("DEFAULT", new JApplicationException()); 144 145 return applicationExceptions; 146 } 147 148 } 149 | Popular Tags |