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 share Proxy in a multicore context?  (Read 7659 times)
amahi
Newbie
*
Posts: 4


View Profile Email
« on: August 21, 2008, 06:09:17 »

Hi,

Can I pass a proxy in the Pipe (for reading data purpose only) to share it between a lot of "core" (module) ?
I hesitate betwen that or to create a Singleton to always access the same proxy. But I affraid if I create singleton, when I dispose the core, I will have some surprise.

Thank's to say me what is the best way!
Logged
danielcsgomes
Full Member
***
Posts: 47

 - daniel@onedesign.com.pt
View Profile Email
« Reply #1 on: August 21, 2008, 08:14:53 »

Hi amahi,

I'm learning Multicore Pipes, and for what i am reading and what i understand about it, i think that you can pass the proxy data as a message through a pipe for the other modules to catch up the message from the pipe. I think to do it you need to use a filter on the modules that will receive that message from the pipe.

Daniel Gomes
« Last Edit: August 21, 2008, 08:18:39 by danielcsgomes » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: August 23, 2008, 11:41:19 »

You just have to be 100% cognizant of the references that Cores* have to each other. Thinking in a modular way, where those each Core is a black box unto itself, with no dependencies on the others is the ideal. Only purely informational messages would be passed between them.

However, to really get things done, Cores need to collaborate and often in a more intimate way. They sometimes need to share bits of themselves with each other.

For instance, a module might create a UIComponent that it will 'export' a reference via pipe message to the shell, or main app, which holds the primary display hierarchy of the clent. The shell will insert this component into its view hierarchy and the user will be able to interact with it. However, before exporting that UIComponent, the module instantiates a Mediator that also has a reference to that UIComponent. So the module is 'mediating' interactions with that view component, even though the shell places a reference to it in its display hierarchy (the main application).

In view-sharing this setup, there are a few important things to keep in mind:

1) The agreement between the module and the shell on the abstract class to be passed, in this case UIComponent. This allows the shell to treat the visual components from all modules the same, whether they are Panels, Datagrids, TileLists, etc.

2) The class is being is shared between the module and shell, here provided by the Flex framework, but in your own app perhaps by a common API library that you create.

3) There must be a coordinated handling by the cores sharing the reference when it comes to reference removal. Whichever core initiates the process must not only do its part but also alert the other one, so as to ensure both sides release all references.

Now to consider your question of the sharing of Proxies.

Imagine for the sake of discussion a Module that is written as a utility, which has a full set of classes and an entire PureMVC apparatus focused on creating and managing the Proxies necessary to talk to Flickr, and also implements a nice caching and undo capability. And instead of exporting view components, it exports Proxies. The Proxies it exports are well defined and actually packaged in a separate API.

If it were just that all the Proxies were exported, then we'd just include the library and deal with it all ourselves, who needs to load a module just to be a simple Proxy factory?

But instead, we export simple proxies that manipulate the data references with an API we expose, and our module is actually an application that manages all the 'frob' authentication and other such stuff that makes developers say 'huh?'.

Send a configuration VO to the module by pipe message, and the module configures itself and awaits further instructions in the form of pipe messages. You may respond by authenticating, fetching datasets, cloning them, and letting the rest of the app have Proxies that interact with the cloned datasets (but don't do all the service interaction). You can expose methods to undo by replacing the dataset with the original, OR, write all the changes back by invoking a Proxy method, which sends a Notification that the module has a Command registered for which calls a RemoteProxy (that doesn't get exported) to the update service with the new data.

Without going much further than that, we can see that we'd be:

1) Sharing references to Proxies which are watched and manipulated in various external cores, but managed in one. We'd place these all in a library exposed to external module developers and used in the exporting module itself.

2) In the exporting module, we'd be in charge of things like instantiation and removal, exporting , caching, service interaction, data integrity logic.

3) In our external cores that are using the exported Proxies, we'd sometimes be listening for their update notifications when data changes, displaying their data and interacting with their methods.

4) All the same caveats as the sharing of view components apply in terms of coordinated teardown.

Hope this provides some perspective,
-=Cliff>

* When I say 'Core', I mean the app or the modules, each has a set of MVCF actors associated with it. When I say 'module' I mean... module. ;)
Logged
Pages: [1]
Print