Bug or feature enchangment? passig Applicationdomain to child injectors

reider's Avatar

reider

17 Jun, 2010 10:11 PM

I am developing a complex modular Flex application where the loader and all the modules use robotlegs. With v1.0.3 and suspenders 1.0.1 there was no problem but when updating to 1.1.1 with suspenders 1.5.1 the modules could not find the mapped definitions.
I figured it's because the injector tried with the main domain so I tried to pass the current domain and I overridden the get injector in the module context with this:

override protected function get injector():IInjector
{

if(!_injector){
    var swiftInjector:SwiftSuspendersInjector = new SwiftSuspendersInjector()
    swiftInjector.setApplicationDomain(ApplicationDomain.currentDomain)
    _injector = swiftInjector
}
return _injector

}

It was still not working because when the SwiftSuspendersInjector created a child it doesn't care about the parent's defined domain it just uses the parameter so If i want to pass the domain I have to override all places where the injector creates a child and pass my domain. Because I used the sources I just modified the SwiftSuspendersInjector to save me some trouble

public function createChild(applicationDomain:ApplicationDomain = null):IInjector
{

var injector:SwiftSuspendersInjector = new SwiftSuspendersInjector();
if(applicationDomain){
    injector.setApplicationDomain(applicationDomain);
}else{
    injector.setApplicationDomain(getApplicationDomain())
}
injector.setParentInjector(this);
return injector;

}

So now if there is no domain in the parameter it uses the parents domain. Maybe there is a better way because it would sure be nice if one existed or maybe there is a reason for doing it like this.

  1. 1 Posted by peterc on 21 Jun, 2010 10:59 PM

    peterc's Avatar

    Not sure this is related. I am also working with Robotlegs 1.1.1. And I haven't run into domain related problem yet. I used ModuleManager and load modules by doing moduleInfo.load(ApplicationDomain.currentDomain). I did have problem in which object was not getting injected correctly. Same code that was working in the main app wasn’t working when running in a module. After experiment with reflection, I find that the reason was because meta tag such as [Inject] got strip out of the module swf files. I add -keep-as3-metadata+=Inject -keep-as3-metadata+=PostConstruct to the complier option and my app start working correctly.

  2. Stray closed this discussion on 10 Feb, 2011 05:28 PM.

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