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

Show Posts

| * |

  Show Posts
Pages: [1]
1  PureMVC Manifold / MultiCore Version / Project Proposal: MultiCore MessageBus on: July 03, 2008, 07:41:50
Hi All,

I have an alternative idea (and basic implementation) for communicating between modules. I have dabbled with j2ee web services and enterprise message buses before, and the problem seems similar. One service needs to talk to another, and to mitigate coupling between the services, they communicate via a Message Bus.

Here's a (hopefully) brief description of what I've implemented thus far.  I want to get feed back to see if this is a utility that could be contributed to puremvc.  I will use the utility regardless, but I wanted to contribute if possible.

The utility consists of the following classes:
MessageBus : Facades register themselves with this singleton class upon creation. In addition, facades will declare here what messages they are interested in, and optionally a transformer to translate the Messages into Notifications.

IMessageTransformer : interface that can be implemented to provide a way of transforming message types into notifications specific to each Module's ApplicationFacade.

MessageTransformer : a default implementation of IMessageTransformer.  This is added by default if no transformer is specified.


Here's an example of how to interact with the MessageBus in my current implementation:
:
override protected function initializeFacade() : void
{
super.initializeFacade();

// Setup message bus connection.
var messageBus : MessageBus = MessageBus.getInstance();
messageBus.registerFacade(NAME, this);

messageBus.registerTransformer(NAME, SessionMessage.LOGIN, new SessionMessageTransformer());
messageBus.registerTransformer(NAME, SessionMessage.LOGOUT, new SessionMessageTransformer());
}

And here's an example of sending a message
:
MessageBus.getInstance().sendMessage(new SessionMessage(SessionMessage.LOGIN));

The message bus receives the message, uses the module-provided transformer to transform the message into a notification specific to the module, and uses the module's facade to send it.

In this way, all messages sent are propagated as notifications to each Facade registered to the message bus.

The only coupling between modules is to the MessageBus, and to the Messages that will be shared between Modules of an application.

Let me know if this would be a valuable contribution to the project!
Russ
2  Announcements and General Discussion / General Discussion / Retrieving URL data for use in a command on: September 19, 2007, 06:58:49
Hi!

I have the following scenario and haven't found any examples where this is done.

I have an account management application that sends out emails to users to confirm registration. In this email is a link to the account management application with an encrypted token used to verify that the user received the email.

The user uses this link to open the flex application and log in. Based on the account status, the flex application gets a signal telling it that the registration needs to be confirmed.

I wanted to get suggestions on how to implement this with puremvc and have the responsibilities in the right place.

Here's what I'm planning so far:
  • AccountProxy receives signal from the server and sends a notification.
  • ApplicationMediator reacts to the notification, getting the email token from the mx.core.Application.application.parameters Array.
  • ApplicationMediator sends a new "confirmRegistration" notification with the data needed to confirm the registration.
  • ConfirmRegistrationCommand reacts to the "confirmRegistration" notification and either calls the AccountProxy to confirm registration with the server, or if the email token isn't set (the user didn't use the email link to log in) sends notification to display a message to the user.

Something about it just seems odd, since the ApplicationMediator is involved only to pick up data needed to confirm the registration. Any suggestions on a cleaner solution?

Thanks!
Russ
3  Announcements and General Discussion / General Discussion / Custom Notifications on: July 16, 2007, 02:13:32
I work in a team environment where I believe it will be beneficial to have custom Notification objects with typed payloads.  For example, I'll have a LoginNotification that would carry a username and password.

The primary reason is so other developers on my team can look at the Notification's definition and know exactly what information they can expect from it.  This way once all the notifications are laid out for an application, my team can code away without needing to check with one another to know what information a notification will contain etc.

The decision I'm faced with is where to put the Notification classes.  Initially I thought that I would put them with the components that send them, but soon found that locating a particular Notification wasn't intuitive.

A second approach is to put the Notification classes in the same package as the ApplicationFacade.  This is similar to defining all the names of your Notifications as static constants within the ApplicationFacade.as file.

A third possibility is to simply add a 'notification' package along with the 'model','view', and 'controller' packages.

Has anyone else had taken the custom notification approach?  Have any suggestions on how to organize the Notification classes?
Pages: [1]