Array Configuration/Injection
Hi,
I need to inject an array with 3 elements object elements all of which implements the same interface.
Any idea how to do that?
Something like:
<NestedObject id="one"
type="{CustObject1}">
</NestedObject>
<NestedObject id="two"
type="{CustObject2}">
</NestedObject>
<NestedObject id="three"
type="{CustObject3}">
</NestedObject>
</ConstructorArgs>
10x,
Claudiu
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Nikos on 20 Aug, 2010 08:56 PM
we need a lot more detail:)
2 Posted by claudiu on 21 Aug, 2010 12:01 PM
basically I pretty much need this scenario:
http://www.herrodius.com/blog/136
I need a way to configure the factory with the parsers inside it.
10x.
Claudiu
Support Staff 3 Posted by Shaun Smith on 21 Aug, 2010 04:16 PM
Hi, I don't understand the question, and I don't see how it relates to Robotlegs?
4 Posted by claudiu on 22 Aug, 2010 09:34 AM
Sorry if I am not being explicit enough.
Basically I am using the same scenario. I have a factory and some parsing classes. the idea that each strategy class can decide is I am using if it can parse it's really neat. The thing Robotlegs to wire my application not Spring As or Parsely so I have no idea how I configure the factory class to be initialized with the parser.
with Spring As this code is configure like this:
When you want to use it you just inject it into your client and that's it. The same goes for parsley only the syntax is more similar to my first post. How can I define the array than the 3 custom parsers inside it?
Hope this makes sense.
10x,
Claudiu
5 Posted by claudiu on 31 Aug, 2010 08:51 AM
I left this aside for a while due to low priority but ultimately I went ahead went this:
Context/Command
var parsers:Array = injector.instantiate(Array);
parsers.push(injector.instantiate(CustomParser1));
parsers.push(injector.instantiate(CustomParser3));
parsers.push(injector.instantiate(CustomParser3));
injector.mapValue(Array, parsers, "parsers");
factory class:
[Inject(name="parsers")]
public class FactoryClass
{
}
Seems to do the trick. Anyone knows a better way of doing this if any ?
10x,
Claudiu
It's a shame though you cannot inject Vectors instead of Arrays. Anyone knows when that will be possible?
Support Staff 6 Posted by Stray on 10 Feb, 2011 05:43 PM
In these cases it's better to wrap your object in a VO - then you can have a Vector of the items rathe than just the array.
Always, always avoid injecting the base classes.
Stray closed this discussion on 10 Feb, 2011 05:43 PM.