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: Unable to retrieve registered Proxy  (Read 8300 times)
ghess
Courseware Beta
Jr. Member
***
Posts: 12


View Profile Email
« on: June 05, 2008, 02:39:29 »

Hi Folks,

I am registering a Proxy that sends a notification in initializeNotifier() to inform the system that the proxy data model has been loaded (I am using a local test stub so it goes very fast). I have a registered Mediator (Registered before the Proxy in my StartupCommand) that listens for the proxies 'init_complete' notification. When the Mediator receives the notification it retrieves the proxy from the facade, but it is null. How can this be, it was registered, initializeNotifier was called...

In debugging I walk through the modules startup command and step over the registration of the proxy. The mediator has a breakpoint in handleNotification and it is triggered before register proxy returns as I step over. I 'think' my proxies multiton key had not been set before initializeNotifier was called (just a guess).

As an added note my proxy is a common proxy. Most of my modules need access to a common VO's so I have a common package with my common VO's proxies ect. I have modeled the multicore demo app and altered it to load/unload modules. This proxy was first loaded by the module shell and all was well. My first loaded module also needs this proxy and registers it to its own facade, but the second time this this problem occurs.

Any help much appreciated.

Thanks,

Greg

Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: June 05, 2008, 07:02:45 »

You're notifying too soon. Wait until onRegister, that way when you send the notification the Proxy will be retrievable.

-=Cliff> 
Logged
ghess
Courseware Beta
Jr. Member
***
Posts: 12


View Profile Email
« Reply #2 on: June 06, 2008, 07:11:09 »

Thanks Cliff,

Sorry, should have seen that in the API docs.

If I now wait to perform my WS calls in onRegister, do I still need to be concerned with the order that I register my Mediators, Proxies and Commands? For example I was concerned that I should have my Mediator that listens for the 'PROXY_INITIALIZED' notification registered before the Proxy that sends the notification.

Much appreciated!

-Greg
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #3 on: June 06, 2008, 07:20:48 »

Yes you do need to consider the order you register things.
-=Cliff>
Logged
ghess
Courseware Beta
Jr. Member
***
Posts: 12


View Profile Email
« Reply #4 on: June 09, 2008, 11:03:26 »

Thanks Cliff,

Respecting the registration order is tricky. If I do all my registrations from one main StartupCommand can I trust that once the last line is executed the system is fully initialized?

BTW: I also send a notification from my StartupCommand to initialize common components such as Header and Footer. So in my main module startupCommand I register subcomponents Startup Commands (HeaderStartup, FooterStartup) and then send the notification to execute them. Do they run in a separate thread? See example below:

:

//Mediator registration
...

//Proxy registration
var usProxy:IProxy = new UserProxy();
facade.registerProxy( usProxy );

/********************* Register Commands ****************************/
facade.registerCommand( Constants.FOOTER_STARTUP, FooterStartupCommand );
facade.registerCommand( Constants.HEADER_STARTUP, HeaderStartupCommand );
//Send the notifications for our children
sendNotification( Constants.FOOTER_STARTUP, module.footer );
sendNotification( Constants.HEADER_STARTUP, module.header );

//At this point can I send out a notification that the initialization is complete or is header and footer init in a separate  thread?

Thank you,

Greg
Logged
Pages: [1]
Print