Fine-grained configuration files
If you have a large number of components that need to be configured in XML, it makes much more sense to split up the information in components.xml
into many small files. Seam lets you put configuration for a class named, for example, com.helloworld.Hello
in a resource named com/helloworld/Hello.component.xml
. (You might be familiar with this pattern, since it is the same one we use in Hibernate.) The root element of the file may be either a <components>
or <component>
element.
The first option lets you define multiple components in the file:
<components>
<component class="com.helloworld.Hello" name="hello">
<property name="name">#{user.name}</property>
</component>
<factory name="message" value="#{hello.message}"/>
</components>
The second option only lets you define or configure one component, but is less noisy:
<component name="hello">
<property name="name">#{user.name}</property>
</component>
In the second option, the class name is implied by the file in which the component definition appears.
Alternatively, you may put configuration for all classes in the com.helloworld
package in com/helloworld/components.xml
.