[webbeans-dev] Minor rewrite

Gavin King gavin at hibernate.org
Thu Dec 4 12:57:48 EST 2008


I got some feedback that section 10.3.4 from the XML configuration is
difficult to read, so I've rewritten it as follows. Should not be a
semantic change.

10.3.4. Fields of a Web Bean
A field of a Web Bean is declared by a direct child element of the Web
Bean declaration. The name of the field is the same as the name of the
element.

If the Web Bean implementation class has exactly one field with the
same name as the child element, then the child element is interpreted
to represent that field.

Otherwise, if the Web Bean implementation class does not have exactly
one field with the specified name, a DefinitionException is thrown by
the Web Bean manager at initialization time.

If more than one child element of a Web Bean declaration represents
the same field of the Web Bean implementation class, a
DefinitionException is thrown by the Web Bean manager at
initialization time.

A field declaration may contain child elements. If a field declaration
has more than one direct child element, and at least one of these
elements is something other than a <value> element in the Web Beans
namespace, a DefinitionException is thrown by the Web Bean manager at
initialization time.

An element that represents a field may declare an injected field, a
producer field or a field with an initial value.

• If the element contains a child <Produces> element in the Web Beans
namespace, a producer field was declared, as defined in Section 3.5.3,
"Declaring a producer field using XML".

• If the element contains a child <value> element in the Web Beans
namespace, a field with an initial value of type Set or List was
declared, as defined in Section 10.3.5, "Field initial value
declarations".

• Otherwise, if the element has exactly one child element, an injected
field was declared, as defined in Section 3.7.2, "Declaring an
injected field using XML".

• If the element has a non-empty body, and no child elements, a field
with an initial value was declared, as defined in Section 10.3.5,
"Field initial value declarations".

• Otherwise, a DefinitionException is thrown by the Web Bean manager
at initialization time.

If a field declaration represents an injected field, the child element
is interpreted as an injection point declaration, as specified in
Section 10.6, "Injection point declarations". If the declared type is
not assignable to the Java type of the field, a DefinitionException is
thrown by the Web Bean manager at initialization time.

The API type declared in XML may be a subtype of the Java field type.
In this case, the Web Bean manager will use the
API type declared in XML when resolving the dependency.


-- 
Gavin King
gavin.king at gmail.com
http://in.relation.to/Bloggers/Gavin
http://hibernate.org
http://seamframework.org




More information about the weld-dev mailing list