Announcement Announcement Module
Collapse
No announcement yet.
Indirect bean property Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Indirect bean property

    Hi,

    Given a class Finder that delivers key-value mappings via a method
    String lookup(String key)

    Can I use this to configure bean properties?

    I am thinking of something like

    <bean id="looky" class="Finder">...

    <bean id="myBean"
    <property name="x"> call looky.lookup("x") </property>
    <property name="y"> call looky.lookup("yyy") </property>
    ...


    Thx!
    Last edited by abelv; Aug 16th, 2008, 02:21 PM.

  • #2
    sad

    i'm quite sad because in spite of several views of the posting nobody seems to know an answer...

    still hoping :-)

    Comment


    • #3
      Well, if you are doing this from the spring bean factory, configure a http://static.springframework.org/sp...onfigurer.html with a custom prefix/postfix, and inject the property that way.

      If you really want a dynamic lookup, then you should abstract the properties into a factory class that knows where to get the data and inject that instead.

      If your properties are changing, mark you bean as 'prototype' so you get a new copy every time from the bean factory.

      Comment


      • #4
        Originally posted by abelv View Post
        i'm quite sad because in spite of several views of the posting nobody seems to know an answer...

        still hoping :-)
        http://static.springframework.org/sp...factory-method

        If that doesn't cut it for you, try:

        http://static.springframework.org/sp...ctoryBean.html

        Cheerio
        Rick

        Comment


        • #5
          solution

          the MethodInvokingFactoryBean works fine - although it is a bit complicated to configure a bean for every parameter that needs to be set.

          anyway - thanks!

          Comment

          Working...
          X