View Full Version : Method with multi arguments
mosmann
Sep 23rd, 2004, 05:01 AM
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:)
jbetancourt
Sep 23rd, 2004, 05:51 AM
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
mosmann
Sep 23rd, 2004, 06:05 AM
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:)
katentim
Sep 23rd, 2004, 06:58 AM
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?
cmgharris
Sep 23rd, 2004, 07:32 AM
Couldn't you write yourself a FactoryBean to instantiate the classes that need this?
Just implement the FactoryBean interface - it's pretty straightforward.
mosmann
Sep 23rd, 2004, 09:52 AM
- - - - - - -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:)
katentim
Sep 24th, 2004, 06:23 AM
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.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.