Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Child ApplicationDomains break the injector #33

Open
fakeasanything opened this issue Sep 1, 2010 · 4 comments
Open

Child ApplicationDomains break the injector #33

fakeasanything opened this issue Sep 1, 2010 · 4 comments
Labels

Comments

@fakeasanything
Copy link

We created a RobotLegs SWF (with SwiftSuspenders) and it worked fine standalone. However, when loading this into another Robotlegs SWF (also with SwiftSuspenders) in a child ApplicationDomain at runtime, injection failed in the child SWF, throwing the following exception:

Exception fault: ReferenceError: Error #1065: Variable MyClassView is not defined.
at flash.system::ApplicationDomain/getDefinition()
at org.swiftsuspenders.injectionpoints::PropertyInjectionPoint/initializeInjection()[/Users/tschneidereit/dev/swiftsuspenders/swiftsuspenders/src/org/swiftsuspenders/injectionpoints/PropertyInjectionPoint.as:58]

So it seems that when a RobotLegs SWF using SwiftSuspenders loads another RobotLegs SWF using SwiftSuspenders in a child ApplicationDomain, injection breaks completely - it seems as though SwiftSuspenders is using the injector/injection settings from the parent domain?

Loading the SWF into the same ApplicationDomain does work, however this does open up other problems for us. We can use this as a workaround for now, but it would be great to find out whether we're doing something wrong, or whether this is an issue with SwiftSuspenders (or indeed RobotLegs). Our investigation has led us to believe this is an issue with SwiftSuspenders.

Is anyone familiar with this problem?

Hope someone can help,

Mani

@Matan
Copy link

Matan commented Sep 1, 2010

Hi Mani,

I had the same problem ( http://github.com/tschneidereit/SwiftSuspenders/issues#issue/31 ) and like you said passing the "current" application domain solves the problem, but if you need to have the child in it's own app domain it fails.

Don't currently know of any fixes for this. :(

@fakeasanything
Copy link
Author

Cheers Matan!

Fingers crossed someone can shed some light on this!

Mani

@vizio360
Copy link

vizio360 commented Feb 3, 2011

Hi guys,

I did load an external robotlegs module in a child Application Domain and it worked.

e.g.
in the mainApp:
load external SWF which is a RobotLegs Module passing a new LoaderContext with a child domain of the current ApplicationDomain.

var childDomain:ApplicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
var context:LoaderContext = new LoaderContext(false, childDomain);

Once the module has loaded you need to pass through the parent injector, which is the injector of the mainAppContext.

In the RobotLegs Module you then pass the following to the constructor of the ModuleContext:

context = new YourContext(this, true, rootInjector, ApplicationDomain.currentDomain);

In this case ApplicationDomain.currentDomain refers to the currentDomain of the swf which is the childDomain we passed in the LoaderContext.
So now your robotlegs module is in its own ApplicationDomain, even though it's a child domain of the mainApp ApplicationDomain.
In this way the Robotlegs module can access the class definitions specified in the mainApp ApplicationDomain.

It worked for us, now we load external Robotlegs modules with no issues.

@darscan
Copy link
Contributor

darscan commented May 10, 2012

ping

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants