Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Modularization and dependency injection / runtime configuration  (Read 9539 times)
letapjar
Newbie
*
Posts: 5


View Profile Email
« 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.
Logged
Tekool
Sr. Member
****
Posts: 192


View Profile WWW Email
« Reply #1 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

Logged
letapjar
Newbie
*
Posts: 5


View Profile Email
« Reply #2 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.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 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>
Logged
Pages: [1]
Print