<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Christophe Herreman &#187; Cairngorm</title>
	<atom:link href="http://www.herrodius.com/blog/category/cairngorm/feed" rel="self" type="application/rss+xml" />
	<link>http://www.herrodius.com/blog</link>
	<description>Thoughts from a software developer</description>
	<lastBuildDate>Thu, 10 Jun 2010 19:08:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Thoughts on Cairngorm 3 and Application Architecture</title>
		<link>http://www.herrodius.com/blog/216</link>
		<comments>http://www.herrodius.com/blog/216#comments</comments>
		<pubDate>Tue, 06 Oct 2009 20:40:25 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[AS3Commons]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Inversion of Control]]></category>
		<category><![CDATA[Lessons learned]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Spring ActionScript]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=216</guid>
		<description><![CDATA[Cairngorm 3 was recently announced by Tom Sugden and Alex Uhlmann and has now been released in beta on the Adobe Opensource site.
Don&#8217;t expect an updated version of the Cairngorm framework as you know it though. Cairngorm 3 is not aiming to be an MVC implementation, and thus moves away from what version 1 and [...]]]></description>
			<content:encoded><![CDATA[<p>Cairngorm 3 was recently announced by <a href="http://blogs.adobe.com/tomsugden/2009/09/coming_soon_cairngorm_3_1.html">Tom Sugden</a> and <a href="http://blogs.adobe.com/auhlmann/archives/2009/10/cairngorm_3_bet.html">Alex Uhlmann</a> and has now been <a href="http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm+3">released in beta</a> on the Adobe Opensource site.</p>
<p>Don&#8217;t expect an updated version of the Cairngorm framework as you know it though. Cairngorm 3 is not aiming to be an MVC implementation, and thus moves away from what version 1 and 2 were, but now consists of a set of patterns and practices, together with a series of libraries that can help to solve common problems.</p>
<p>The Patterns &#038; Practices Group at Microsoft have been promoting <a href="http://www.codeplex.com/CompositeWPF">a similar mindset</a> for quite some time actually: Prism &#8211; patterns &#038; practices Composite Application Guidance for WPF</p>
<p>I can only encourage this decision as it is exactly how I personally think about application design and architecture, especially in Flex and AIR applications. This is also what we are trying to do with <a href="http://www.springactionscript.org">Spring ActionScript</a>: our main goal is to provide a solid Inversion of Control container that supports multiple configuration options (XML, MXML, metadata driven component scanning, &#8230;) and promote it as a foundation to build applications (and frameworks), with or without your favorite MVC framework. Although we are working on a set of base classes that provide infrastructure for your application (under the name MVCS) with Application Events, Controllers, Abstractions for service layers, &#8230; by no means do we want to market the Spring ActionScript framework as yet another MVC implementation. (You might wonder why we are calling it MVCS then, and I&#8217;m actually wondering the same&#8230; I guess marketing and buzzwords in the opensource world are also important. All kidding aside, the name is certainly subject to change).</p>
<p><strong>What&#8217;s in a name</strong></p>
<p>Since this is a complete change of direction for the Cairngorm framework (which it actually no longer is) I would have expected a new name. Continuing to use Cairngorm as a name is in my opinion a bad move and will cause major confusion amongst developers and other people involved in the development process. I think the best thing for Adobe, or at least their Technical Services department, would be to let go of the name and choose a new, fresh name that moves away from the past. (Besides that, who can pronounce &#8220;Cairngorm&#8221;.)</p>
<p><strong>Dependencies</strong></p>
<p>I noticed that some of the modules that Cairngorm 3 provides depend on other libraries/frameworks, and in general the <a href="http://www.spicefactory.org/parsley/">Parsley</a> application framework. While Parsley is certainly a major player amongst the IoC/application frameworks, and I sincerely respect the author&#8217;s work, I don&#8217;t think this is a good decision. In case you are wondering: Yes, I would say the same thing if they decided to depend on Spring ActionScript.</p>
<p>The usage and choice of a concrete dependency will have consequences for the adoption and integration of the libraries that Cairngorm 3 provides. Think about it: Why would you want to pull in Parsley, perhaps only to use some of its Reflection API, if you are already running on Spring ActionScript or any other IoC container?</p>
<p>We, the Spring ActionScript team, have actually questioned ourselves about this in the past and have therefore decided to move all the common and reusable code from Spring ActionScript into a set of libraries known as the <a href="http://www.as3commons.org">AS3Commons</a> project. In that respect, I&#8217;m a bit disappointed that for instance the <a href="http://www.as3commons.org/as3-commons-reflect">AS3Commons Reflect</a> library is not used for reflection purposes, since I think it is more abstracted and unintrusive than a subset of an all-encompassing application framework. Perhaps this may be our fault of not promoting the libraries and the project enough. However, I certainly think that AS3Commons could be a wonderful project and would help to provide common libraries not only to Flex and AIR developers, but to ActionScript 3 developers in general, if it were embraced by the community.</p>
<p><strong>Flex and MVC</strong></p>
<p>Given that RIA technolgies are still evolving at a very fast pace, it is really remarkable to see the huge amount of MVC implementations appear. Not specifically aimed at Cairngorm (at least the previous versions), but rather at almost all MVC architectures available for Flex development, my personal feeling and experience is that the use of MVC architectures in the Adobe RIA space is almost a dogmatic thing and is not needed in most cases. The problem is that people just take an MVC framework as it is and implement it in their applications. More than often not questioning whether or not its usage is justified. Things that could easily and cleverly be solved are ripped apart across layers of the architecture, introducing levels of indirection that are in most cases not needed. The only thing they add is complexity and counter-intuitive development practices.</p>
<p>One of the main arguments for using an MVC framework is that the code is &#8220;easy to understand&#8221;. Of course the code will be easy to understand if you have been developing with the framework of choice for the N-th time or if you have been digging into the code for a serious amount of time, but ask a newcomer to look at the code and try to explain to you what it is actually doing&#8230; I think you&#8217;ll be surprised by the responses.</p>
<p>I&#8217;m not saying that the use of a particular MVC framework is de facto a bad thing, but the &#8220;religious&#8221; use and the blind adoption and implementation make a framework a killer for your application. I would encourage everyone to start their next project without an MVC framework and just use the Flex framework with a healthy knowledge of design and presentation patterns. And even if you are using an MVC implementation, think about each layer you introduce, why you need it and the pros and cons it brings.</p>
<p><strong>Conclusion</strong></p>
<p>It&#8217;s good to see that Adobe is rethinking their approach to RIA architecture and development practices. I also hope that they will be more open to community input and feedback than they were in the past. Although they did several attempts at engaging the community, I don&#8217;t think they really succeeded in that. If not open enough, people will just continue to fork the &#8220;framework&#8221; and provide extensions that will end up in alternative implementations anyway.</p>
<p>I&#8217;m looking forward to seeing how all of this evolves.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/216/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>What is bothering you about Cairngorm?</title>
		<link>http://www.herrodius.com/blog/152</link>
		<comments>http://www.herrodius.com/blog/152#comments</comments>
		<pubDate>Tue, 05 Aug 2008 20:26:17 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/152</guid>
		<description><![CDATA[In the last months there have been several blog posts about the evil that is Cairngorm. People are complaining about the framework on mailing lists and on forums and when talking to other developers, a lot of them seem to dislike Cairngorm, mostly in favor of other frameworks. Some projects I consulted on (often too [...]]]></description>
			<content:encoded><![CDATA[<p>In the last months there have been several blog posts about the evil that is Cairngorm. People are complaining about the framework on mailing lists and on forums and when talking to other developers, a lot of them seem to dislike Cairngorm, mostly in favor of other frameworks. Some projects I consulted on (often too late) were actually being refactored/rewritten to move away from Cairngorm.</p>
<p>I noticed however that the opinions often lacked strong arguments, if any at all, that were convincable enough for me to truly dig into other frameworks. In some cases, I felt that the choice of a framework was based on a hype and prejudgement towards other frameworks. In particular PureMVC is getting a lot of attention and I can&#8217;t remember how many developers I have heard saying that they were using PureMVC just because &#8220;Cairngorm sucks&#8221;.</p>
<p>Don&#8217;t get me wrong. I certainly don&#8217;t want to start a religious war between the Cairngorm, PureMVC and other framework followers. I&#8217;m all for a little &#8220;competition&#8221; because I believe it drives innovation. We&#8217;re even offering extensions to both frameworks in Prana and since people are using them, there certainly will be good reasons that justify the use of one of the two frameworks.</p>
<p>However, I was wondering what your opinion was on Cairngorm. What in particular is it that you don&#8217;t like about Cairngorm and if you could change things, what would they be? On the other hand, what things do you absolutely like about the framework?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/152/feed</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Prana enabled Cairngorm Store</title>
		<link>http://www.herrodius.com/blog/131</link>
		<comments>http://www.herrodius.com/blog/131#comments</comments>
		<pubDate>Sun, 24 Feb 2008 21:38:02 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Inversion of Control]]></category>
		<category><![CDATA[Prana]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/131</guid>
		<description><![CDATA[Following up on Douglas McCarroll's modified Cairngorm Store update, I thought I'd take this a step further and add a Prana application context to configure the business delegates and the service locator. This example has support for mock delegates that contain hardcoded local data and is also able to connect to php services using Remote [...]]]></description>
			<content:encoded><![CDATA[<p>Following up on <a href="http://www.brightworks.com/flex_ability/?p=61">Douglas McCarroll's modified Cairngorm Store update</a>, I thought I'd take this a step further and add a Prana application context to configure the business delegates and the service locator. This example has support for mock delegates that contain hardcoded local data and is also able to connect to php services using Remote Objects and AMFPHP.</p>
<p>This examples replaces the older Cairngorm Store example that was configured to work with AMF0 and Renaun Erickson's RemoteObjectAMF0. It now uses the latest beta version of AMFPHP and the AMF3 protocol. The services are hosted on this domain so you don't need to setup AMFPHP in order to see this in action.</p>
<p>The code is currently in svn and can be checked out at <a href="http://prana.svn.sourceforge.net/viewvc/prana/trunk/samples/PranaCairngormStore/">http://prana.svn.sourceforge.net/viewvc/prana/trunk/samples/PranaCairngormStore/</a>. This sample will also be included in the next release.</p>
<p>Here's a snippet from the readme file:</p>
<p>***</p>
<p>The following files have been added/changed in order to add Prana configuration support for business delegates and service locator:</p>
<p>* Main.mxml: added application context loader and forced compilation of configured classes</p>
<p>package com.adobe.cairngorm.samples.store.business<br />
* BaseBusinessDelegateMock.as: implements IResponderAware, removed responder constructor argument<br />
* CreditCardDelegate.as: extends AbstractRemoteObjectDelegaten, implements ICreditCardDelegate<br />
* CreditCardDelegateMock.as: implements ICreditCardDelegate<br />
* ICreditCardDelegate.as: interface for credit card delegates<br />
* IProductDelegate.as: interface for product delegates<br />
* ProductDelegate.as: extends AbstractRemoteObjectDelegaten, implements IProductDelegate<br />
* ProductDelegateMock.as: implements IProductDelegate</p>
<p>package com.adobe.cairngorm.samples.store.commands<br />
* GetProductsCommand.as: added delegate lookup via ShopModelLocator<br />
* ValidateCreditCardCommand.as: added delegate lookup via ShopModelLocator</p>
<p>package com.adobe.cairngorm.samples.store.model<br />
* ShopModelLocator.as: added creditCardDelegate and productDelegate variables to configure business delegates</p>
<p>***</p>
<p>As a result, we can now lookup the implementation of our business delegates in the commands instead of instantiating new ones. The commands are completely unaware of the implementation of the business delegates. One note though: since we are not creating new delegate instances, we need to set the responder as a property of the delegate before calling its methods.</p>
<div class="igBar"><span id="lactionscript-4"><a href="#" onclick="javascript:showPlainTxt('actionscript-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-4">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> delegate:IProductDelegate = ShopModelLocator.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">productDelegate</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">delegate.<span style="color: #006600;">responder</span> = <span style="color: #0066CC;">this</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">delegate.<span style="color: #006600;">getProducts</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Here's how the application is configured in the application context to use the mock delegates:</p>
<div class="igBar"><span id="lxml-5"><a href="#" onclick="javascript:showPlainTxt('xml-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-5">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"shopModelLocator"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"com.adobe.cairngorm.samples.store.model.ShopModelLocator"</span> <span style="color: #000066;">factory-method</span>=<span style="color: #ff0000;">"getInstance"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"creditCardDelegate"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"com.adobe.cairngorm.samples.store.business.CreditCardDelegateMock"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/property<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"productDelegate"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"com.adobe.cairngorm.samples.store.business.ProductDelegateMock"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/property<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/object<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And here's how the remote object delegates and the service locator are configured:</p>
<div class="igBar"><span id="lxml-6"><a href="#" onclick="javascript:showPlainTxt('xml-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">XML:</span>
<div id="xml-6">
<div class="xml">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"endPoint"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"String"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;constructor</span>-arg <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"http://www.herrodius.com/amfphp/gateway.php"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/object<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"serviceLocator"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"org.pranaframework.cairngorm.CairngormServiceLocator"</span> <span style="color: #000066;">factory-method</span>=<span style="color: #ff0000;">"getInstance"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"productService"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"mx.rpc.remoting.mxml.RemoteObject"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"destination"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"GenericDestination"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"endpoint"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>endPoint<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ref<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/property<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"source"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"com.adobe.cairngorm.samples.store.business.ProductService"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/object<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/property<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"creditCardService"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"mx.rpc.remoting.mxml.RemoteObject"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"destination"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"GenericDestination"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"endpoint"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;ref<span style="font-weight: bold; color: black;">&gt;</span></span></span>endPoint<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/ref<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/property<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"source"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"com.adobe.cairngorm.samples.store.business.CreditCardService"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/object<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/property<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/object<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"shopModelLocator"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"com.adobe.cairngorm.samples.store.model.ShopModelLocator"</span> <span style="color: #000066;">factory-method</span>=<span style="color: #ff0000;">"getInstance"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"creditCardDelegate"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"com.adobe.cairngorm.samples.store.business.CreditCardDelegate"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/property<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"productDelegate"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;object</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"com.adobe.cairngorm.samples.store.business.ProductDelegate"</span><span style="font-weight: bold; color: black;">/&gt;</span></span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/property<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/object<span style="font-weight: bold; color: black;">&gt;</span></span></span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/131/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Prana 0.3 released!</title>
		<link>http://www.herrodius.com/blog/95</link>
		<comments>http://www.herrodius.com/blog/95#comments</comments>
		<pubDate>Sat, 24 Nov 2007 10:07:04 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Prana]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=95</guid>
		<description><![CDATA[I'm proud to announce that Prana 0.3 has been released.
Some of the key features and updates:

major update to the core IoC container
support for templates in the application context (blog post)
support for initializing objects in the application context (Log example)
compliancy with Spring application contexts
event sequencing in Cairngorm (blog post)
several utilities

In the coming days, I'll post some [...]]]></description>
			<content:encoded><![CDATA[<p>I'm proud to announce that Prana 0.3 has been released.</p>
<p>Some of the key features and updates:</p>
<ul>
<li>major update to the core IoC container</li>
<li>support for templates in the application context (<a href="http://www.herrodius.com/blog/?p=96">blog post</a>)</li>
<li>support for initializing objects in the application context (<a href="http://www.herrodius.com/blog/?p=88">Log example</a>)</li>
<li>compliancy with Spring application contexts</li>
<li>event sequencing in Cairngorm (<a href="http://www.herrodius.com/blog/?p=80">blog post</a>)</li>
<li>several utilities</li>
</ul>
<p>In the coming days, I'll post some more about the new features.</p>
<p>General info: <a href="http://www.pranaframework.org">http://www.pranaframework.org</a><br />
Download: <a href="http://sourceforge.net/project/showfiles.php?group_id=194107&#038;package_id=228809&#038;release_id=556250">SourceForge Download Page</a></p>
<p>Changes in version 0.3 (24.11.2007)<br />
-----------------------------------</p>
<p>General<br />
* added Movie sample application based on article by Martin Fowler<br />
* improved documentation<br />
* moved Cairngorm related classes to org.pranaframework.cairngorm<br />
* Cairngorm Store sample now has different configuration of service locator</p>
<p>Package org.pranaframework.cairngorm<br />
* added support for event sequencing<br />
* CairngormFrontController now checks for commands implementing the ICommands interface<br />
* implementation of CairngormServiceLocator</p>
<p>Package org.pranaframework.errors<br />
* added ClassNotFoundError for retrieving a class by name when class was not found</p>
<p>Package org.pranaframework.ioc<br />
* added serializer to create an application context from an object<br />
* added support for initializing object with IInitializingObject<br />
* added support for templates in application context<br />
* added support for &lt;map&gt; definitions, parsed to Dictionary<br />
* added support for &lt;list&gt; definitions, parsed to ArrayList<br />
* made container spring context compliant<br />
* improved error handling when creating object from object definitions<br />
* rewrote preprocessing of xml application context, now using chain of preprocessors<br />
* fixed creation of object without id, id is now auto generated<br />
* fixed order for object definitions so that they no longer need to be chronological</p>
<p>Package org.pranaframework.reflection<br />
* added metadata introspection<br />
* added "getFullName" method to Method class<br />
* changed arguments in "invoke" method from ... to array</p>
<p>Package org.pranaframework.utils<br />
* added "forName" method in ClassUtils for retrieving Class objects via class names<br />
* added "getParentClass" method in ClassUtils that returns the parent class of a given class<br />
* added "isSubclassOf" method in ClassUtils that returns if a class extends another class<br />
* added StringUtils<br />
* added DisplayObjectContainerUtils<br />
* added MethodInvoker to support initializing objects from application context<br />
* added "state" method to Assert class<br />
* changed TypeConverter so that it can return Class objects</p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/95/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tony Hillerson on Cairngorm Business Delegates with Prana</title>
		<link>http://www.herrodius.com/blog/82</link>
		<comments>http://www.herrodius.com/blog/82#comments</comments>
		<pubDate>Wed, 17 Oct 2007 09:10:26 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Prana]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=82</guid>
		<description><![CDATA[In case you haven't read this, Tony Hillerson has posted an article on configuring a Business Delegate Factory for Cairngorm with Prana. This allows you to quickly switch between different implementations for testing or production purposes.
Read it at http://thillerson.blogspot.com/2007/10/delegate-factories-with-prana.html
It's good to see that the community is picking up Prana and benefits from it. Keep on [...]]]></description>
			<content:encoded><![CDATA[<p>In case you haven't read this, <a href="http://thillerson.blogspot.com/">Tony Hillerson</a> has posted an article on configuring a Business Delegate Factory for <a href="http://labs.adobe.com/wiki/index.php/Cairngorm">Cairngorm</a> with <a href="http://sourceforge.net/projects/prana/">Prana</a>. This allows you to quickly switch between different implementations for testing or production purposes.</p>
<p>Read it at <a href="http://thillerson.blogspot.com/2007/10/delegate-factories-with-prana.html">http://thillerson.blogspot.com/2007/10/delegate-factories-with-prana.html</a></p>
<p>It's good to see that the community is picking up Prana and benefits from it. Keep on supporting the project guys, thx!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/82/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Chaining commands in Cairngorm with Prana</title>
		<link>http://www.herrodius.com/blog/80</link>
		<comments>http://www.herrodius.com/blog/80#comments</comments>
		<pubDate>Thu, 11 Oct 2007 15:09:09 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Prana]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=80</guid>
		<description><![CDATA[Problem
We want to be able to execute commands in a sequence, where each command needs to be executed after the previous command has finished. This can be right after a call to execute() in case the command only implements ICommand, or after the invocation of the result() or fault() method, in case the command implements [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong></p>
<p>We want to be able to execute commands in a sequence, where each command needs to be executed after the previous command has finished. This can be right after a call to execute() in case the command only implements ICommand, or after the invocation of the result() or fault() method, in case the command implements the IResponder interface and fetches some remote data.</p>
<p><span id="more-80"></span><br />
The way to do this in Cairngorm is to let your command extend SequenceCommand - which acts as an abstract base class for commands that are executed in a sequence. Then you assign a value to the nextEvent property and call the executeNextCommand() method. This is done in the execute() method, the result() or fault() handler of the command. Each sequence command contains logic that says which command to execute next.</p>
<p>This has a major drawback though: since the sequence logic is coded in the commands themselves, it is very hard - not to say impossible without extra conditional logic - to reuse the command outside a sequence or in another sequence.</p>
<p><strong>Solution</strong></p>
<p>Instead of extending SequenceCommand and coding the sequence logic in the commands themselves, let's define a sequence of events outside of the commands. The commands themselves should not extend SequenceCommand. This will allow us to create "standalone" commands that have their specific task and then chain them into a variety of sequences.</p>
<p><strong>Explanation</strong></p>
<p>The solution <a href="http://sourceforge.net/projects/prana/">Prana</a> offers comes in the form of the EventSequence class. As said earlier, we want to have a non-intrusive way of defining sequences of events/commands without the need to code sequence logic in the commands. As an example, let's take an event that causes the user to log in, after which another event is dispatched to fetch the latest private messages for that user.</p>
<p>In Cairngorm we would have the following:</p>
<div class="igBar"><span id="lactionscript-14"><a href="#" onclick="javascript:showPlainTxt('actionscript-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-14">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> LoginCommand <span style="color: #0066CC;">extends</span> SequenceCommand <span style="color: #0066CC;">implements</span> IResponder <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #808080; font-style: italic;">// code left out...</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> result<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> user:UserVO = <span style="color: #0066CC;">data</span>.<span style="color: #006600;">result</span> as UserVO;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ModelLocator.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">user</span> = user;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// here is the problem, the command knows what command to execute next</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">// we can't reuse this command in another chain</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nextEvent = <span style="color: #000000; font-weight: bold;">new</span> LoadPrivateMessagesEvent<span style="color: #66cc66;">&#40;</span>user.<span style="color: #006600;">id</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; executeNextCommand<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>In the above code, the sequence logic in the result() handler prevents us from reusing the command outside of the sequence or in another sequence. This will most often result in duplicate code which makes the code base hard to maintain.</p>
<p>Looking at the flow of events and commands, we see that in most cases (but not all) a command will update some property in the ModelLocator. This is a good practice, because it keeps your commands consistent across your application: a command executes, proxies a remote call through a business delegate, adds itself as a responder to the remote call, updates the ModelLocator in the result() or fault() handler.</p>
<p><strong>Example</strong></p>
<p>Let's dive into an example of the EventSequence. I'll explain the different parts individually:</p>
<div class="igBar"><span id="lactionscript-15"><a href="#" onclick="javascript:showPlainTxt('actionscript-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-15">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> sequence:EventSequence = <span style="color: #000000; font-weight: bold;">new</span> EventSequence<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// add a first event to the sequence which let's the user log in</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sequence.<span style="color: #006600;">addSequenceEvent</span><span style="color: #66cc66;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; LoginUserEvent,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#91;</span>username, <span style="color: #0066CC;">password</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// add a second event which fetches the latest private messages</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sequence.<span style="color: #006600;">addSequenceEvent</span><span style="color: #66cc66;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; LoadPrivateMessagesEvent,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #000000; font-weight: bold;">new</span> Property<span style="color: #66cc66;">&#40;</span>ModelLocator.<span style="color: #006600;">getInstance</span>, <span style="color: #ff0000;">"user"</span>, <span style="color: #ff0000;">"id"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #000000; font-weight: bold;">new</span> Property<span style="color: #66cc66;">&#40;</span>ModelLocator.<span style="color: #006600;">getInstance</span>, <span style="color: #ff0000;">"user"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// start the sequence</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sequence.<span style="color: #006600;">dispatch</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><strong>Explanation</strong></p>
<p>First thing we need to do of course is create a sequence. We can do this by creating an instance of EventSequence.</p>
<p>Next, the sequence expects us to define different events in it so that it knows when to fire which event. We do this by calling addSequenceEvent() on the sequence and passing in the properties of the event we want the sequence to dispatch.</p>
<div class="igBar"><span id="lactionscript-16"><a href="#" onclick="javascript:showPlainTxt('actionscript-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-16">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sequence.<span style="color: #006600;">addSequenceEvent</span><span style="color: #66cc66;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; LoginUserEvent,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#91;</span>username, <span style="color: #0066CC;">password</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The first argument is the class of the event. In our case this is LoginUserEvent with has 2 constructor parameters: username and password. These parameters are defined in the second argument of the addSequenceEvent() method as an array.</p>
<p>There are 2 options:<br />
1. we pass in concrete values<br />
2. we pass in an instance of Property which let's us define a lookup of a property (if you are familiar with BindingUtils, you will already know how this works)</p>
<p>The first option, passing in a concrete value, is quite straight forward. In case of the LoginUserEvent we pass in the credentials of the user, which will normally be fetched from the text inputs of the login form. So the definition of this could look as follows:</p>
<div class="igBar"><span id="lactionscript-17"><a href="#" onclick="javascript:showPlainTxt('actionscript-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-17">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sequence.<span style="color: #006600;">addSequenceEvent</span><span style="color: #66cc66;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; LoginUserEvent,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#91;</span>username, <span style="color: #0066CC;">password</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The second option is a property that will be evaluated or looked up at runtime and is defined by a host and a chain. In case of the second event, we want to pass in the user's id, but we can only do this if the user is defined in the ModelLocator and has a valid id (this will be after executing the LoginUserCommand). Doing the following wouldn't work (don't worry about the 3rd argument for now):</p>
<div class="igBar"><span id="lactionscript-18"><a href="#" onclick="javascript:showPlainTxt('actionscript-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-18">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sequence.<span style="color: #006600;">addSequenceEvent</span><span style="color: #66cc66;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; LoadPrivateMessagesEvent,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#91;</span>ModelLocator.<span style="color: #006600;">getInstance</span>.<span style="color: #006600;">user</span>.<span style="color: #006600;">id</span><span style="color: #66cc66;">&#93;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#91;</span><span style="color: #000000; font-weight: bold;">new</span> Property<span style="color: #66cc66;">&#40;</span>ModelLocator.<span style="color: #006600;">getInstance</span>, <span style="color: #ff0000;">"user"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This will result in a runtime error (null pointer exception) because we want to pass in the concrete value of the user's id when we define the sequence. Since the ModelLocator does not contain a valid user instance at that point, this won't work. Therefor we need to define the value as a property of which the value will be "looked up" when we really need it (that is when firing the next event in our case).</p>
<p>The property defines a host: that is the variable that contains - or better will contain - the needed parameters for the event. In our case this is the model locator, so ModelLocator.getInstance(). The remaining arguments of the property instance are a chain of properties of the host defined as strings. So to get the user's id from the model locator we would define the following:</p>
<div class="igBar"><span id="lactionscript-19"><a href="#" onclick="javascript:showPlainTxt('actionscript-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-19">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">var</span> p:Property = <span style="color: #000000; font-weight: bold;">new</span> Property<span style="color: #66cc66;">&#40;</span>ModelLocator.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">"user"</span>, <span style="color: #ff0000;">"id"</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The 3rd argument of the addSequenceEvent() defines a trigger that will instruct the next event to be fired. In the example above, the next event will get fired when the user property of the model locator has changed.</p>
<p>After we have defined the sequence, all we need to do is call it's dispatch method. Also, the event/command mapping is still defined in the front controller, just like you would do without sequences. We do not need to specify any custom mapping.</p>
<p><strong>Where to create sequences?</strong></p>
<p>Normally I create a subclass of EventSequence and define the sequence in the constructor. I then instantiate the sequence in the appropriate view and dispatch it from there.</p>
<p>An alternative approach could be that the front controller has support for defining sequences. We would then have a centralized place for specifying these sequences instead of having them scattered in different classes. In this case there should also be a way of launching a sequence from the view. I don't have an answer for that right now, but I'll put some thinking into that.</p>
<p><strong>What if the command does not update the model locator.</strong></p>
<p>There will be times when a command does not update a property in the model locator. So we don't really have a point in time when we know we should trigger the next event. To solve this, the CairngormFrontController registers every executing command in a central registry called the PendingCommandRegistry. The command then has do decide when its action is finished and unregister itself:</p>
<div class="igBar"><span id="lactionscript-20"><a href="#" onclick="javascript:showPlainTxt('actionscript-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-20">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> result<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">data</span>:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #808080; font-style: italic;">// do some stuff</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #808080; font-style: italic;">// ... now let the sequence know this command is done</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #808080; font-style: italic;">// we do this indirectly by unregistering</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; PendingCommandRegistry.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">unregister</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">this</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>When calling unregister, the event sequence will get notified of this and trigger the next event if any. Note: this is not yet fully implemented in SVN and is more of a theory at the moment.</p>
<p><strong>Conclusion</strong></p>
<p>I personally think that this is a good approach to chaining events/commands. Especially because of the non-intrusive way this problem is handled. If you have any ideas or comments, feel free to leave them here or join the <a href="http://sourceforge.net/mailarchive/forum.php?forum_name=prana-user">Prana list</a> or <a href="http://tech.groups.yahoo.com/group/cairngorm-devel/">Cairngorm list</a> so we can discuss this.</p>
<p>Hope you enjoyed this and keep on coding!</p>
<p><strong>Update 2007/10/12</strong>: added explanation of the triggers argument of addSequenceEvent()</p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/80/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Adding a check for ICommand to addCommand() in Cairngorm</title>
		<link>http://www.herrodius.com/blog/81</link>
		<comments>http://www.herrodius.com/blog/81#comments</comments>
		<pubDate>Wed, 10 Oct 2007 19:09:28 +0000</pubDate>
		<dc:creator>Christophe</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Prana]]></category>

		<guid isPermaLink="false">http://www.herrodius.com/blog/?p=81</guid>
		<description><![CDATA[Once in a while, when adding event/command mappings in Cairngorm's frontcontroller, I mistakingly add an event instead of a command class to the addCommand() method. Here's an example:
PLAIN TEXT
Actionscript:




addCommand&#40;UserEvent.LOAD, LoadUserEvent&#41;; 






while it really should be:
PLAIN TEXT
Actionscript:




addCommand&#40;UserEvent.LOAD, LoadUserCommand&#41;; 






This is just a mistake when typing fast and with code completion but it can take a while [...]]]></description>
			<content:encoded><![CDATA[<p>Once in a while, when adding event/command mappings in <a href="http://labs.adobe.com/wiki/index.php/Cairngorm">Cairngorm</a>'s frontcontroller, I mistakingly add an event instead of a command class to the addCommand() method. Here's an example:</p>
<div class="igBar"><span id="lactionscript-24"><a href="#" onclick="javascript:showPlainTxt('actionscript-24'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-24">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addCommand<span style="color: #66cc66;">&#40;</span>UserEvent.<span style="color: #0066CC;">LOAD</span>, LoadUserEvent<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>while it really should be:</p>
<div class="igBar"><span id="lactionscript-25"><a href="#" onclick="javascript:showPlainTxt('actionscript-25'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-25">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">addCommand<span style="color: #66cc66;">&#40;</span>UserEvent.<span style="color: #0066CC;">LOAD</span>, LoadUserCommand<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This is just a mistake when typing fast and with code completion but it can take a while until you find out what you did wrong. To prevent this, I decided to override addCommand() in Prana's CairngormFrontController and add in a check to see if the commandRef argument actually is an implementation of ICommand.</p>
<p>You can checkout this code from <a href="http://sourceforge.net/projects/prana/">Prana's SVN</a> if you like, or you can build a custom version of Cairngorm with the following code:</p>
<div class="igBar"><span id="lactionscript-26"><a href="#" onclick="javascript:showPlainTxt('actionscript-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-26">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> addCommand<span style="color: #66cc66;">&#40;</span>commandName:<span style="color: #0066CC;">String</span>, commandRef:<span style="color: #000000; font-weight: bold;">Class</span>, useWeakReference:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>commands<span style="color: #66cc66;">&#91;</span> commandName <span style="color: #66cc66;">&#93;</span> != <span style="color: #000000; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> CairngormError<span style="color: #66cc66;">&#40;</span> CairngormMessageCodes.<span style="color: #006600;">COMMAND_ALREADY_REGISTERED</span>, commandName <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">null</span> == commandRef<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"The commandRef argument cannot be null"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> classDescription:<span style="color: #0066CC;">XML</span> = describeType<span style="color: #66cc66;">&#40;</span>commandRef<span style="color: #66cc66;">&#41;</span> as <span style="color: #0066CC;">XML</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> implementsICommand:<span style="color: #0066CC;">Boolean</span> = <span style="color: #66cc66;">&#40;</span>classDescription.<span style="color: #006600;">factory</span>.<span style="color: #006600;">implementsInterface</span>.<span style="color: #66cc66;">&#40;</span>@<span style="color: #0066CC;">type</span> == getQualifiedClassName<span style="color: #66cc66;">&#40;</span>ICommand<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">length</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>!implementsICommand<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Error</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"The commandRef argument '"</span> + commandRef + <span style="color: #ff0000;">"' should implement the ICommand interface"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; commands<span style="color: #66cc66;">&#91;</span> commandName <span style="color: #66cc66;">&#93;</span> = commandRef;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; CairngormEventDispatcher.<span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> commandName, executeCommand, <span style="color: #000000; font-weight: bold;">false</span>, <span style="color: #cc66cc;color:#800000;">0</span>, useWeakReference <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>This should save you some time in the future.</p>
<p>On a side note, I have been working on an alternative approach to chaining events/commands in Cairngorm. The code is already in Prana's SVN but I haven't had the time to blog about this. Check it out if you're interested and mail me if you want a code example. In the meantime, I'll work a blogpost with an example on how to use it and will publish this by the end of the week.</p>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.herrodius.com/blog/81/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
