Vadim Gritsenko skrev:
Daniel Fagerstrom wrote:
Vadim Gritsenko skrev:
Daniel Fagerstrom wrote:
...
A more complete example would be that we define a number of components, that could be spread out in many independent blocks:

<bean id="o.a.c.f.validation.WidgetValidatorBuilderSelector/length"
     class="o.a.c.f.validation.impl.LengthValidatorBuilder">
 <property name="type" value="length"/>
</bean>

<bean id="o.a.c.f.validation.WidgetValidatorBuilderSelector/range"
     class="o.a.c.f.validation.impl.RangeValidatorBuilder">
 <property name="type" value="range"/>
</bean>
...

Then we have components like that use the widget components that currently depends on selectors, they could be configured like this:

<bean id="o.a.c.f.f.WidgetDefinitionBuilder/form"
     class="org.apache.cocoon.forms.formmodel.FormDefinitionBuilder">
 <property name="type" value="form"/>
 <property name="widgetValidatorBuilders">
   <bean class="o.a.c...BeansByIntefaceFactoryBean">
     <property name="inteface"
               value="o.a.c.f.f.WidgetValidatorBuilder"/>
   </bean>
 </property>
 ...
</bean>

Where the BeanByIntefaceFactoryBean looks up the beans fulfilling a certain interface as described above.

It is rather verbose, but yes, it does solve the problem.

It is verbose, but using the xml extension mechanism in Spring 2.0 we could create a shorter notation as e.g.:

 <bean id="o.a.c.f.f.WidgetDefinitionBuilder/form"
      class="org.apache.cocoon.forms.formmodel.FormDefinitionBuilder">
  <property name="type" value="form"/>
  <property name="widgetValidatorBuilders"
            selector:interface="o.a.c.f.f.WidgetValidatorBuilder"/>
  ...
 </bean>

Or even shorter by parsing the bean id for "/form", don't think it is such a good idea to parse ids though.

/Daniel

Reply via email to