Announcement Announcement Module
No announcement yet.
Method with multi arguments Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Method with multi arguments

    How can I setup something like this ?

    <bean id="test" class="myclass">
    <method name="doSomething">
    <ref name="otherbean" />

    I want to have this, to integrate old stuff.

    Thanx for help


  • #2
    Not sure the intent, but there is the <replaced-method> injection approach.

    See the reference manual: Arbitrary method replacement

    --- J. Betancourt


    • #3
      Thank you. But this does not help.
      You can imagine this like a property with more than 1 argument.

      class SomeClass
      public void setNamedValue(String name, Object value) {...};
      public Object getNamedValue(String name) {...};



      • #4
        Spring supports setter injection (single arg.) and constructor (multiple args.). I don't see why multiple arg. setter couldn't be added in future. I'll suggest on mailing list.

        If legacy means you can't change the source I think you're in trouble. Can you subclass and use multiple setters or constructor injection?


        • #5
          Couldn't you write yourself a FactoryBean to instantiate the classes that need this?
          Just implement the FactoryBean interface - it's pretty straightforward.


          • #6
            Method with multi arguments

            - - - - - - -8<- - - - - -
            cmgharris: ..
            Hm.. i will take a look on this FactoryBean stuff.
            - - - - - - ->8- - - - - -

            - - - - - - -8<- - - - - -
            Maybe you can give me an advice to solve something like this:

            I have a class wich stores some zonemapping for Domains. f.I. you can set this with

            addZoneMapping(String domain,Zone zone)

            sure i could use a list. But then addZoneMapping have to validate which objects in List and so on. I want to put this logic out of this function.

            - - -
            maybe i should told something about my background.

            i have written something like spring about a year before. This framework is very limited in it's way. You can simply build instances from Classes an set some of its propertys. (automatic Object conversion etc. included). Config was not XML. So setting this stuff above you write simply:

            .addZoneMapping = [$Securezone];
            .addZoneMapping = [$Securezone];
            .addZoneMapping = [$Securezone];

            but now i want to switch this stuff to swingframework..

            thank you for your advice



            • #7
              This problem doesn't seem to fit Spring's current IoC implementation.

              I'd recommend looking at Spring resources - see section 3.11.3. "Using resources within Spring" in Spring's reference document and the "" package in Javadocs. You can then re-use your existing code to process the resource. Hope this helps.