I added a prototype (read partial) implementation for Abstract Beans, and uploaded the
patch in Jira (JBKERNEL-10).
What I did was:
- introduce a new ControllerMode called ABSTRACT
- install abstract beans as controller contexts with ABSTRACT mode, which are never
progressing past the DESCRIBED state
- modify the initialVisitor to merge parent data with current bean data (i.e. copy
metadata from parent if missing in child or merge if it is a collection - this allows
child beans to override parent bean settings).
Copying metadata from parent to child works - what needs to be done is to make sure that
this is done in a semantically correct way for all types of metadata, for eliminating
ambiguities.
One issue I encountered is that metadata such as PropertyMetaData is stored in a Set in
the BeanMetaData, yet PropertyMetaData does not implement equals() and hashCode().
This leads to the possibility of writing definitions such as:
| <bean ... >
| <property name="someProperty">Value1</property>
| <property name="someProperty">Value2</property>
| </bean>
|
, and given that both elements will generate a PropertyMetaData and they will be stored in
a HashSet, it is hard to tell which one of the two will be used to set the value when the
bean is instantiated.
Currently, merging the two property sets (parent and child) can produce a similar effect,
if the same property is defined in the parent and child. It is possible to elliminate
duplicates in the merging process,but the main challenge is in making this process
generic.
Using an implementation for equals() that is based on PropertyMetaData.getName() would be
a poor hack, since it is hard to say that two PropertyMetaData instances having the same
name but different values are equal. I am currently considering using a Map for the
merging process, and we might use something similar inside AbstractBeanMetaData.
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4245973#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...