Results 1 to 7 of 7

Thread: Method with multi arguments

  1. #1

    Default 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. #2
    Join Date
    Aug 2004
    Location
    u.s.a
    Posts
    399

    Default

    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

  3. #3

    Default

    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

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    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. #5
    Join Date
    Aug 2004
    Location
    Carlisle, UK
    Posts
    184

    Default

    Couldn't you write yourself a FactoryBean to instantiate the classes that need this?
    Just implement the FactoryBean interface - it's pretty straightforward.
    Chris Harris
    Carlisle, UK

  6. #6

    Default 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

  7. #7
    Join Date
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,104

    Default

    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.

Similar Threads

  1. Order of Bean definitions matters?
    By cfuser in forum Container
    Replies: 2
    Last Post: Oct 21st, 2005, 10:29 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. Replies: 1
    Last Post: Jul 28th, 2005, 05:08 PM
  4. could not satisfy dependencies
    By springuser in forum Container
    Replies: 4
    Last Post: Apr 26th, 2005, 01:15 PM
  5. Replies: 1
    Last Post: Apr 25th, 2005, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •