Author: pete.muir(a)jboss.org
Date: 2010-06-05 13:38:24 -0400 (Sat, 05 Jun 2010)
New Revision: 6406
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlElement.java
core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java
core/trunk/impl/src/main/java/org/jboss/weld/xml/MergedElements.java
Log:
WELD-467
Modified: core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlElement.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlElement.java 2010-06-05
17:38:08 UTC (rev 6405)
+++ core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlElement.java 2010-06-05
17:38:24 UTC (rev 6406)
@@ -39,7 +39,7 @@
private URL file;
private Element element;
- private BeansXmlElement(URL file, Element element)
+ BeansXmlElement(URL file, Element element)
{
super();
this.file = file;
@@ -59,11 +59,6 @@
return null;
}
- public static BeansXmlElement of(URL file, Node element)
- {
- return new BeansXmlElement(file, (Element) element);
- }
-
public List<Class<?>> getClasses(ResourceLoader resourceLoader)
{
List<Class<?>> classes = new ArrayList<Class<?>>();
Modified: core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java 2010-06-05
17:38:08 UTC (rev 6405)
+++ core/trunk/impl/src/main/java/org/jboss/weld/xml/BeansXmlParser.java 2010-06-05
17:38:24 UTC (rev 6406)
@@ -42,6 +42,9 @@
*/
public class BeansXmlParser
{
+
+ public static final String NAMESPACE = "http://java.sun.com/xml/ns/javaee";
+
private final Iterable<URL> beansXmls;
private final ResourceLoader resourceLoader;
private EnabledClasses enabledClasses = null;
@@ -74,7 +77,7 @@
public void parse()
{
- DocumentBuilder documentBuilder = getDocumentBuilder();
+ DocumentBuilder documentBuilder = createDocumentBuilder();
MergedElements mergedElements = new MergedElements();
for (URL beansXml : beansXmls)
{
@@ -82,13 +85,21 @@
{
continue;
}
- Document document = getDocument(documentBuilder, beansXml);
- mergedElements.merge(beansXml, document);
+ Document document = loadDocument(documentBuilder, beansXml);
+ if (document.getNamespaceURI() == null)
+ {
+ mergedElements.merge(beansXml, document, "*");
+ }
+ else
+ {
+ mergedElements.merge(beansXml, document, NAMESPACE);
+ }
+
}
enabledClasses = EnabledClasses.of(mergedElements, resourceLoader);
}
- private Document getDocument(DocumentBuilder documentBuilder, URL beansXml)
+ private Document loadDocument(DocumentBuilder documentBuilder, URL beansXml)
{
Document document;
InputStream in = null;
@@ -151,11 +162,13 @@
}
}
- private DocumentBuilder getDocumentBuilder()
+ private DocumentBuilder createDocumentBuilder()
{
try
{
- return DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ factory.setNamespaceAware(true);
+ return factory.newDocumentBuilder();
}
catch (ParserConfigurationException e)
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/xml/MergedElements.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/xml/MergedElements.java 2010-06-05
17:38:08 UTC (rev 6405)
+++ core/trunk/impl/src/main/java/org/jboss/weld/xml/MergedElements.java 2010-06-05
17:38:24 UTC (rev 6406)
@@ -41,25 +41,25 @@
private List<BeansXmlElement> interceptorsElements = new
ArrayList<BeansXmlElement>();
- public void merge(URL url, Document beansXmlDocument)
+ public void merge(URL url, Document beansXmlDocument, String namespace)
{
Element documentElement = beansXmlDocument.getDocumentElement();
- alternativesElements.addAll(getNamedElement(url, documentElement,
"alternatives", MULTIPLE_ALTERNATIVES));
- interceptorsElements.addAll(getNamedElement(url, documentElement,
"interceptors", MULTIPLE_INTERCEPTORS));
- decoratorsElements.addAll(getNamedElement(url, documentElement,
"decorators", MULTIPLE_DECORATORS));
+ alternativesElements.addAll(findNamedElement(url, documentElement, namespace,
"alternatives", MULTIPLE_ALTERNATIVES));
+ interceptorsElements.addAll(findNamedElement(url, documentElement, namespace,
"interceptors", MULTIPLE_INTERCEPTORS));
+ decoratorsElements.addAll(findNamedElement(url, documentElement, namespace,
"decorators", MULTIPLE_DECORATORS));
}
- private List<BeansXmlElement> getNamedElement(URL url, Element beans, String
name, XmlMessage multipleViolationMessage)
+ private List<BeansXmlElement> findNamedElement(URL url, Element beans, String
namespace, String name, XmlMessage multipleViolationMessage)
{
List<BeansXmlElement> elements = new ArrayList<BeansXmlElement>();
- NodeList nodeList = beans.getElementsByTagName(name);
+ NodeList nodeList = beans.getElementsByTagNameNS(namespace, name);
if (nodeList.getLength() > 1)
{
throw new WeldXmlException(multipleViolationMessage);
}
else if (nodeList.getLength() == 1)
{
- BeansXmlElement element = BeansXmlElement.of(url, nodeList.item(0));
+ BeansXmlElement element = new BeansXmlElement(url, (Element) nodeList.item(0));
elements.add(element);
}
return elements;