Permalink
Browse files

Initial Injector ApplicationDomain fix

  • Loading branch information...
darscan committed Sep 21, 2010
1 parent 175288e commit 5017a7599740a787fcccd6c9664d1ccbc84d6fc4
@@ -56,10 +56,26 @@ package org.robotlegs.adapters
public function createChild(applicationDomain:ApplicationDomain = null):IInjector
{
var injector:SwiftSuspendersInjector = new SwiftSuspendersInjector();
- injector.setApplicationDomain(applicationDomain);
+ injector.setApplicationDomain(applicationDomain);
injector.setParentInjector(this);
return injector;
}
+
+ /**
+ * @inheritDoc
+ */
+ public function get applicationDomain():ApplicationDomain
+ {
+ return getApplicationDomain();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function set applicationDomain(value:ApplicationDomain):void
+ {
+ setApplicationDomain(value);
+ }
}
}
@@ -149,5 +149,15 @@ package org.robotlegs.core
*/
function hasMapping(clazz:Class, named:String = ""):Boolean;
+ /**
+ * @return The Application Domain
+ */
+ function get applicationDomain():ApplicationDomain;
+
+ /**
+ * @param value The Application Domain
+ */
+ function set applicationDomain(value:ApplicationDomain):void;
+
}
}
@@ -10,6 +10,7 @@ package org.robotlegs.mvcs
import flash.display.DisplayObjectContainer;
import flash.events.Event;
import flash.events.IEventDispatcher;
+ import flash.system.ApplicationDomain;
import org.robotlegs.adapters.SwiftSuspendersInjector;
import org.robotlegs.adapters.SwiftSuspendersReflector;
@@ -130,6 +131,7 @@ package org.robotlegs.mvcs
{
_contextView = value;
// Hack: We have to clear these out and re-map them
+ _injector.applicationDomain = getApplicationDomainFromContextView();
_commandMap = null;
_mediatorMap = null;
_viewMap = null;
@@ -147,7 +149,7 @@ package org.robotlegs.mvcs
*/
protected function get injector():IInjector
{
- return _injector ||= new SwiftSuspendersInjector();
+ return _injector ||= createInjector();
}
/**
@@ -269,14 +271,32 @@ package org.robotlegs.mvcs
startup();
}
+ /**
+ * @private
+ */
+ protected function createInjector():IInjector
+ {
+ var injector:IInjector = new SwiftSuspendersInjector();
+ injector.applicationDomain = getApplicationDomainFromContextView();
+ return injector;
+ }
+
/**
* @private
*/
protected function createChildInjector():IInjector
+ {
+ return injector.createChild(getApplicationDomainFromContextView());
+ }
+
+ /**
+ * @private
+ */
+ protected function getApplicationDomainFromContextView():ApplicationDomain
{
if (contextView && contextView.loaderInfo)
- return injector.createChild(contextView.loaderInfo.applicationDomain);
- return injector.createChild();
+ return contextView.loaderInfo.applicationDomain;
+ return ApplicationDomain.currentDomain;
}
}

0 comments on commit 5017a75

Please sign in to comment.