Hi,
The Cairngorm doesn't allow multiple independent applications to work
together (each one with his own ServiceLocator and Controller) if they
are being loader inside a Loader component inside the same environment
(i.e, a swf file with a Loader, witch can load one of a lot of available
applications). Let's call it appLoad
This occurs because Cairngorm allows toe register only one
ServiceLocator per applications. Se, if you load an application (appA,
for instance) in this Loader, a ServiceLocator will be registered, no in
the loaded swf, but in the swf that loaded the appA - the swf that
contains the Loader (appLoad). You change the loaded application,
loading appB, the appA's ServiceLocator will continue to exist, an
appB's ServiceLocator won't registered.
The best solutions for this is make Cairngorm to accept multiple
ServiceLocators.
To a better understatement, here's a practical example: Imagine a
enterprise Portal. Let's say we have a main swf file (
Portal.mxml) which
contains the portal header, the portal footer, sidebar notes, etc, and a
content Loader component. In this loader, different kinds of
applications can the loaded: the Portal home page, appA, appB, etc. All
this content that can be loaded isn't in the Portal.mxml file for
architectural factors, to now load too much the main swf file,
maintain independent applications, etc.
But each of these applications that may be loaded in the Loader
component has his own ServiceLocator. Own Delegate, own Commands, and
son on. With the actual Cairngorm implementation, *all* the applications
remote services (remoteObject, WebService, etc) that will be loaded into
must have been inside *only* one ServiceLocator, the one that will be
instantiated in Portal.mxml. This way, each new developed application
will push down a new version of Portal.mxml, since the ServiceLocator
will need to be updated.
To solve this problem I made a few Cairngorm updates to allow it to
register an Array of ServiceLocators. This way it's possible that each
applications has their own ServiceLocator (with only needed remote
services), making possible the above implementation without Portal
changes, and only developing new applications, that will be loaded in
the Loader component.
I was hoping this feature to be available in Cairngorm 2.0, but it isn't
there - yet. Since I think this is a recurring problem, with easy
solutions, that provides more flexibility for this micro-architecture, I
would like to suggest this fature to be implemented in Cairngorm.
By the way, I also did another small update: unregister the Command from
EventBroadcaster when an application be unloaded. What motivated me was
more or less the same for the ServiceLocator updated, unloading from the
EventBroadcaster Commands that probably don't exist anymore (since the
loaded application in Loader has been changed).
I'm attaching a proof of concept application (built in Flex 1.5) with my
mods. To maintain the original Cairngorm code for side by side
comparison, in this example I created the ServiceLocatorEx and the FrontControllerEx. I think this
modifications will be worth for Cairngorm and community. Maybe the
Cairngorm team have an specific reason to didn't make this way. I would
like to hear opinions ans suggestions (even about the Portal way - using
Loader component). I'm also open for questions about my ideas.
Thanks,
Bruno Martins
--
Bruno Gustavo Martins
Mobile: (55)(11)9585-9587
bruno@...
experience everywhere
http://www.dclick.com.br/blog