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: How to get configuration data to proxies/delegates  (Read 8155 times)
sleekdigital
Newbie
*
Posts: 2


View Profile Email
« on: June 07, 2008, 06:44:57 »

Suppose you use an xml file to store configuration values for your app.  And a lot of the URL's used to access data are part of that configuration.  What is the recommended way to apply that configuration to a PureMVC based app?  Right now I am loading the configuration xml file using a proxy ( a startup proxy using the startup manager utility to be more specific).  Other proxies and delegates are the actors that will need the urls from the configuration.  So I have proxies accessing the configuration proxy.  Delegates don't have access to the Facade (and thus can't access the configuration proxy) so I was thinking the proxy might pass the url to the delegate.  I would like to hear other approaches to this problem.
Logged
JJfutbol
Sr. Member
****
Posts: 53


View Profile WWW Email
« Reply #1 on: July 08, 2008, 10:47:25 »

This is a great question and wanted to share what I do. In this case from the Proxy I would pass along the URL to the Delegate that it should use. This way if the Delegate will point to a new service it will need some sort of URL, whether its a dot notation path to a CFC (ColdFusion Component) or say a HTTPService.

Once I've loaded up the configuration I actually place it in the ApplicationFacade since I need it easily accessible by the entire system. It drives a lot of different parts of an application so figured the best place for that was as a property in the ApplicationFacade. Curious to hear what others have to say as well.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: July 10, 2008, 05:31:20 »

I use a Proxy to fetch the xml config and hold it as its data object. Set the service's resultFormat to 'E4X'.

The Proxy exposes  the bits of the configuration via e4x expressions used inside implicit getters, so that the Proxy appears to have them as read only properties.

Then anything needing the config just retrieves the Proxy and reads the props.

-=Cliff>
Logged
lowpitch
Jr. Member
**
Posts: 10


View Profile Email
« Reply #3 on: July 13, 2008, 12:21:45 »

Hi Cliff,

Just a little question to add here... I have multiple proxies which all need to retrieve data from the same XMLRPC service (each one calling different methods of that service). I'm going to shift the calls to the service out into a Delegate to avoid a bit of repetition, but I'm hitting a minor stumbling block here.

The config data which defines the URL etc of the service is loaded into a ConfigProxy before anything else happens.

Obviously, the delegate needs to get access from the ConfigProxy, but doesn't natively have access to the facade. It seems my two options are...

1. From within my delegate, I could do something along the lines of ...
ApplicationFacade.getInstance (blahblahblah).retrieveProxy (ConfigProxy.NAME) as ConfigProxy;
... to access the config info.

2. Each Proxy which instantiates an instance of the delegate to perform some kind of server call could pass the config data into the Delegate. This seems a bit messy, as I was hoping to avoid constantly passing the config data around.

How would you handle such a situation? Where would your Delegate get its config data from - would it retrieve the ConfigProxy itself, or have the data passed in from whatever Proxy was invoking it?

Interested in your thoughts.

Many thanks,
Toby
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 on: July 13, 2008, 01:39:35 »

Write that Delegate as a Proxy, and you'll have facade access, it can be long-lived, and other Proxies can retrieve it and make calls, setting themselves as responders.
-=Cliff>
Logged
lowpitch
Jr. Member
**
Posts: 10


View Profile Email
« Reply #5 on: July 13, 2008, 03:58:41 »

Nice idea - that'd fit nicely into my implementation. Thank you.
Logged
Pages: [1]
Print