4 Replies Latest reply on Nov 16, 2007 4:19 AM by Ales Justin

    Nested property reference

    Trustin Lee Apprentice

      Hi,

      I am currently trying to make Apache MINA Microcontainer friendly. It's already very Springframework friendly so I think it should be JBossMC friendly already, but I want to clarify one thing - nested property reference.

      In Springframework, I can access other POJO subproperties like the following:

      <bean id="beanX" ...>
       <property name="propA.propB" value="C"/>
      </bean>
      
      <bean id="beanY" ...>
       <property name="propC" ref="beanX.propA.propB" />
      </bean>
      


      Can Microcontainer refer nested properties like the example above?

      Thanks in advance. Microcontainer rocks!

        • 1. Re: Nested property reference
          Ales Justin Master

           

          "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 Lee Apprentice

             

            "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
              Ales Justin Master

               

              "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.