This content has been marked as final.
Show 4 replies
-
1. Re: Nested property reference
alesj Nov 15, 2007 4:34 AM (in response to trustin)"trustin" wrote:
Can Microcontainer refer nested properties like the example above?
Currently we don't support anything like this.<bean id="beanX" ...> <property name="propA.propB" value="C"/> </bean>
This one I don't like, since it means instantiating an anonymous bean with a lot less control for propA.<bean id="beanY" ...> <property name="propC" ref="beanX.propA.propB" /> </bean>
This can be trivially added to our inject element:<inject bean="beanX" property="propA.propB"/>
Will post this 2nd example on the MC dev forum. And we'll see what response we get. :-)"trustin" wrote:
Microcontainer rocks!
;-) -
2. Re: Nested property reference
trustin Nov 15, 2007 8:49 PM (in response to trustin)"alesj" wrote:
<bean id="beanX" ...> <property name="propA.propB" value="C"/> </bean>
This one I don't like, since it means instantiating an anonymous bean with a lot less control for propA.
It actually doesn't create any anonymous bean but it's identical to the following Java code:beanX.getPropA().setPropB("C");
It's often very useful when you want to modify a property of a read-only property (i.e. propA = read only, propB = writable)."alesj" wrote:
<bean id="beanY" ...> <property name="propC" ref="beanX.propA.propB" /> </bean>
This can be trivially added to our inject element:<inject bean="beanX" property="propA.propB"/>
Sounds great! -
3. Re: Nested property reference
alesj Nov 16, 2007 4:08 AM (in response to trustin)"trustin" wrote:
It actually doesn't create any anonymous bean but it's identical to the following Java code:beanX.getPropA().setPropB("C");
It's often very useful when you want to modify a property of a read-only property (i.e. propA = read only, propB = writable).
Aha, I see. Meaning that a propA is already instantiated in beanX.
But how often do you want to do/use that?
OK, both examples of course have a current workaround, just with more XML. :-)
What we could do for the first example is something analog to our value-factory, but instead of getting the value, we would set the value, nesting it if necessary. -
4. Re: Nested property reference
alesj Nov 16, 2007 4:19 AM (in response to trustin)Moving discussion to dev forum:
- http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4105349