Author: pete.muir(a)jboss.org
Date: 2009-03-24 08:54:58 -0400 (Tue, 24 Mar 2009)
New Revision: 2179
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java
Log:
minor
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java 2009-03-24
10:41:17 UTC (rev 2178)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/ParseXmlHelper.java 2009-03-24
12:54:58 UTC (rev 2179)
@@ -1,6 +1,7 @@
package org.jboss.webbeans.xml;
import java.io.IOException;
+import java.lang.annotation.Annotation;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
@@ -61,7 +62,41 @@
throw new DefinitionException("There are multiple packages containing a Java
type with the same name '" + className + "'");
}
+
+ public static <T extends Annotation> Class<? extends T>
loadAnnotationClass(Element element, Class<T> expectedType, XmlEnvironment
environment, Map<String, Set<String>> packagesMap)
+ {
+ List<Class<? extends T>> classesList = new ArrayList<Class<?
extends T>>();
+ String className = element.getName();
+ String prefix = element.getNamespacePrefix();
+ for (Map.Entry<String, Set<String>> packagesEntry :
packagesMap.entrySet())
+ {
+ if (prefix.equalsIgnoreCase(packagesEntry.getKey()))
+ {
+ Set<String> packages = packagesEntry.getValue();
+ for (String packageName : packages)
+ {
+ String classPath = packageName + "." + element.getName();
+ try
+ {
+ classesList.add(environment.loadAnnotation(classPath, expectedType));
+ }
+ catch (ResourceLoadingException e)
+ {
+ }
+ }
+ }
+ }
+
+ if (classesList.size() == 0)
+ throw new DefinitionException("Could not find '" + className +
"'");
+
+ if (classesList.size() == 1)
+ return classesList.get(0);
+
+ throw new DefinitionException("There are multiple packages containing a Java
type with the same name '" + className + "'");
+ }
+
public static void checkProduces(Element element, AnnotatedClass<?> beanClass)
{
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java 2009-03-24 10:41:17
UTC (rev 2178)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/xml/XmlParser.java 2009-03-24 12:54:58
UTC (rev 2179)
@@ -175,12 +175,12 @@
List<Element> children = element.elements();
for (Element child : children)
{
- AnnotatedClass<? extends Annotation> deploymentClass =
ParseXmlHelper.loadElementClass(child, Annotation.class, environment, packagesMap);
+ Class<? extends Annotation> deploymentClass =
ParseXmlHelper.loadAnnotationClass(child, Annotation.class, environment, packagesMap);
// if(deploymentClass.getAnnotation(DeploymentType.class) == null)
// throw new DefinitionException("<Deploy> child <" +
element.getName() + "> must be a deployment type");
- deploymentClasses.add(deploymentClass.getRawType());
+ deploymentClasses.add(deploymentClass);
}
haveAnyDeployElement = true;
return deploymentClasses;
Show replies by date