Announcement Announcement Module
Collapse
No announcement yet.
Method with multi arguments Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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">
    <value>name</value>
    <ref name="otherbean" />
    </method>
    </bean>

    I want to have this, to integrate old stuff.

    Thanx for help

    mm

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

    See the reference manual: 3.3.3.2. Arbitrary method replacement

    --- J. Betancourt

    Comment


    • #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) {...};
      }

      thanx
      mm

      Comment


      • #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?

        Comment


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

          Comment


          • #6
            Method with multi arguments

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

            - - - - - - -8<- - - - - -
            katentim:
            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 = www.domain.de [$Securezone];
            .addZoneMapping = www.domain.de [$Securezone];
            .addZoneMapping = www.domain.de [$Securezone];

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


            thank you for your advice

            mm

            Comment


            • #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 "org.springframework.core.io" package in Javadocs. You can then re-use your existing code to process the resource. Hope this helps.

              Comment

              Working...
              X