[weld-dev] beans.xsd validation forbeans.xml

Pete Muir pmuir at redhat.com
Mon Jun 7 03:47:53 EDT 2010


On 6 Jun 2010, at 21:01, Nicklas Karlsson wrote:

> I think this comes from the fact that it's theoretically possible to have multiple beans.xml entries for a single BDA currently and that is sort of a cross-beans.xml-check.

Exactly.

> If Pete nukes the multiple beans.xml support that should rightfully disappear, I think.

Not going to happen. BDA doesn't always map 1-1 to a physical jar.

> 
> On Sun, Jun 6, 2010 at 10:54 PM, Marcin Mieszek <marcin.mieszek at gmail.com> wrote:
> Hi,
> 
> I am working right now on issue:
> Weld WELD-379Use beans.xsd for validation of beans.xml
> 
> 1. Currently in MergedElements class there is a logic that checks
> ifsome elements occur more then once, which is not allowed:
> 
>   private List<BeansXmlElement> getNamedElement(URL url, Element
> beans, String name, XmlMessage multipleViolationMessage)
>   {
>      List<BeansXmlElement> elements = new ArrayList<BeansXmlElement>();
>      NodeList nodeList = beans.getElementsByTagName(name);
>      if (nodeList.getLength() > 1)
>      {
>         throw new WeldXmlException(multipleViolationMessage);
>      }
>      else if (nodeList.getLength() == 1)
>      {
>         BeansXmlElement element = BeansXmlElement.of(url, nodeList.item(0));
>         elements.add(element);
>      }
>      return elements;
>   }
> 
> 
> Such files arenot valid according to XSD schema neither. I am planning
> to add XSD validation during parsing of the file - it means that it
> won't be possible to get error with message one of:
>   @MessageId("001203") MULTIPLE_ALTERNATIVES,
>   @MessageId("001204") MULTIPLE_DECORATORS,
>   @MessageId("001205") MULTIPLE_INTERCEPTORS,
> 
> Please let me know how you would like to proceed with it as it is more
> functional question then technical. For schema errors I will add new
> message XSD_SCHEMA_ERROR.
> 
> 2. Minor issue: all test beans.xml files must be changed after adding
> schema validation so that it references correct namespace:
> 
> <beans xmlns="http://java.sun.com/xml/ns/javaee"
>   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>   xsi:schemaLocation="
>      http://java.sun.com/xml/ns/javaee
>      http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
> 
> I will prepare the patch for this one as well.

No. We need to support beans.xml with no schema definition as well. In this case, we assume the default schema is for http://java.sun.com/xml/ns/javaee.




More information about the weld-dev mailing list