PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: letapjar on February 01, 2011, 05:07:59



Title: Modularization and dependency injection / runtime configuration
Post by: letapjar on February 01, 2011, 05:07:59
I am trying to design an app that will connect to various social networks - and that may run in either flash player or in AIR.

To that end - I need some help in properly designing the module structure so that the proper service proxies can be configured at runtime. For Example - the Actionscript Facebook graph API has separate singeltons for the flashplayer and for AIR - I have programmed my code to an interface - The rest of the code expects the SocialNetwrokProxy to implement the SocialNetwork  interface.  But how do I make it so that I can  configure which proxy to use at runtime? 

Perhaps an xml file that is read at runtime to choose the correct proxy depending on which social network the user is connecting through?

Any help on modularization and runtime configuration would be greatly appreciated.


Title: Re: Modularization and dependency injection / runtime configuration
Post by: Tekool on February 02, 2011, 03:21:30
Yep I think the XML file is the good approach.

I personnaly use a command included in the StartupCommand MacroCommand as the last entry to start the loading of the config. When the loading ends I create a ConfigProxy which is later responsible to give access to configuration. It defines methods as ConfigProxy.getString(propertyName), ConfigProxy.getInt(propertyName), etc. when I need my service URL I simply call something like : facade.retrieveProxy("CONFIG_PROXY").getString("URL").

If you have more than one files to load, you can use the PureMVC loadup utility to help in loading XML and other dependencies : http://trac.puremvc.org/Utility_AS3_Loadup



Title: Re: Modularization and dependency injection / runtime configuration
Post by: letapjar on February 19, 2011, 06:19:48
does anyonehave any examples of how to do this with the deployment configuration utility?

It would be great to be able to leverage existing & tested utilities rather than rolling my own.


Title: Re: Modularization and dependency injection / runtime configuration
Post by: puremvc on February 20, 2011, 12:25:53
I do need to create a demo using that utility. It's an approach I've long used in various production apps, and its pretty simple and easy. I'm looking at adding it to an app I'm working on right now actually, so I'll be touching it soon. Perhaps I'll cook up the demo soon.

-=Cliff>