tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/620-child-injector-rules-and-lazy-initializationRobotlegs: Discussion 2018-10-18T16:35:41Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/173741172012-07-19T07:26:16Z2012-07-19T07:26:16ZChild injector rules and Lazy initialization<div><p>Hi Samuel,</p>
<p>Sorry for the late response, but I hoped that Till, Stray or
Shaun would answer your question. I’ve notified them, but
they are probably busy with rl2…</p>
<p>Could it be that the problem is caused by your custom injector
not knowing which ApplicationDomain to use?<br>
How does your SamInjector() look like?</p>
<p>The original Injector createChildInjector method looks like
this:</p>
<pre>
<code>
public function createChildInjector(applicationDomain:ApplicationDomain=null) : Injector
{
var injector : Injector = new Injector();
injector.setApplicationDomain(applicationDomain);
injector.setParentInjector(this);
return injector;
}</code>
</pre></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/173741172012-07-19T09:11:30Z2012-07-19T09:11:30ZChild injector rules and Lazy initialization<div><p>Thank's Ondina.</p>
<p>About SamInjector, sorry, it's a rest of my tests.<br>
The problem exits with the base Injector class.</p>
<p>Few additional informations:<br>
I use robotlegs 1.5.2 (based on SwiftSuspender 1.6.0 if I
remember).<br>
I've tryed with [master] branch of Swift Suspender (tschneidereit
github repo) and the issue still persists.</p></div>Samuel Déaltag:robotlegs.tenderapp.com,2009-10-18:Comment/173741172012-07-19T11:55:26Z2012-07-19T11:55:26ZChild injector rules and Lazy initialization<div><p>Samuel,</p>
<p>I might be very wrong, but you have these mappings:</p>
<p>parent.mapSingleton(RequiredObject);</p>
<p>and</p>
<p>child.mapSingleton(RequiredObject);</p>
<p>Since the child injector has already a mapping, RequiredObject,
mpped in the parent, won’t be used.</p>
<p>“The child injectors forward all injection requests they
don’t have a mapping for to their parent injector.“<br>
From here: <a href=
"https://github.com/tschneidereit/SwiftSuspenders/blob/childinjectors/README.textile">
https://github.com/tschneidereit/SwiftSuspenders/blob/childinjector...</a></p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/173741172012-07-19T12:21:37Z2012-07-19T12:21:37ZChild injector rules and Lazy initialization<div><p>Hey Samuel,</p>
<p>sorry for not replying earlier - I missed this post.</p>
<p>Can you try the Robotlegs build here:<br>
<a href=
"https://github.com/tschneidereit/robotlegs/downloads">https://github.com/tschneidereit/robotlegs/downloads</a>
and see if that<br>
changes things? It contains Swiftsuspenders 2 and I think I
remember<br>
fixing an issue that sounded a lot like yours.</p>
<p>cheers,<br>
till</p></div>Till Schneidereittag:robotlegs.tenderapp.com,2009-10-18:Comment/173741172012-07-19T12:22:44Z2012-07-19T12:22:45ZChild injector rules and Lazy initialization<div><p>Yes, this is my issue.</p>
<p>I need diffenrent RequiredObject per injector, but I would like
the objects originaly mapped in parent to be injected with parent
instances of dependencies.</p>
<p>The child injector forward the instanciation of ComposedObject
to it's parent, but don't forward the 'hydratation' (I mean fulfill
all the injection points of the new instance, is this word
understandable?)</p>
<p>I would my child injectors to forward both to parent if they
don't have themselves the ComposedObject definition.</p>
<p>I think a custom rule can do that, but I failed implementing
it.</p></div>Samuel Déaltag:robotlegs.tenderapp.com,2009-10-18:Comment/173741172012-07-19T12:35:36Z2012-07-19T12:35:39ZChild injector rules and Lazy initialization<div><p>Hi Till, thank you for responding</p>
<p>I've just tried with this swc and the issue still persists.</p>
<p>I would like to say it's not necessarily a bug, juste an
behavior of swiftSuspender I would like to override.<br>
I don't know which behavior you think is the most natural.</p></div>Samuel Déal