Flex: Cairngorm (MVC), SpringActionscript (IOC) and other Cairngorm Extensions
Posted by Jai on August 19, 2009
In this post I will cover brief about the flex Cairngorm framework , integration with SpringActionscript framework, SpringActionscript Cairngorm extension and other available cairngorm extensions and which may fit where in terms of specific tasks.
On a whole, agenda is:
- Cairngorm framework – Flex MVC framework, available resources and how to get started.
- SpringActionscript framework – IOC framework, how to get started and how it helps.
- SpringActionscript Cairngorm extension – How it helps in following best practices and how to use it.
- Cairngorm UM extension – UM extension for specific operations.
There are many Flex MVC frameworks available and why Cairngorm for me, please have a look at Flex now, then & tomorrow…
The first impression of the cairngorm you will have is the lightweight micro-architecture. What it means that it will give you the direction to follow the best practices of flex in easy and quick way and as you move adopt as per the requirements.
Official Website: Cairngorm Download and get started.
Plugin: IDE plugin available at site. (helps in creating command and controller).
Discussion Group: Follow the discussion group.
Maven Integration: Use the below code for maven dependency.
<dependency> <groupId>com.adobe.cairngorm</groupId> <artifactId>cairngorm</artifactId> <version>2.2.1</version> <type>swc</type> </dependency>
There are few IOC framework available but being a java developer, I am fan of Spring and here it is an extension of that SpringActionscript 🙂, earlier known as Prana Framework. Like spring, you can use this framework for object injection. Have a look at the home page to get started.
Maven Integration: Use the following dependencies and repository entries to get started.
<repository> <id>yoolab.org-releases</id> <name>Yoolab.org releases repository</name> <url>http://dev.yoolab.org/maven/content/repositories/</url> <layout>default</layout> </repository>
<dependency> <groupId>org.springextensions.actionscript</groupId> <artifactId>spring-actionscript-cairngorm</artifactId> <version>0.8</version> <type>swc</type> </dependency> <dependency> <groupId>org.springextensions.actionscript</groupId> <artifactId>spring-actionscript-core</artifactId> <version>0.8</version> <type>swc</type> </dependency> <dependency> <groupId>org.as3commons</groupId> <artifactId>as3commons-reflect</artifactId> <version>1.0.0</version> <type>swc</type> </dependency> <dependency> <groupId>org.as3commons</groupId> <artifactId>as3commons-lang</artifactId> <version>1.0.0-SNAPSHOT</version> <type>swc</type> </dependency> <dependency> <groupId>org.as3commons</groupId> <artifactId>as3commons-logging</artifactId> <version>1.0.0</version> <type>swc</type> </dependency>
Sometimes the best way to learn about the best practices is to go through the open source code available. The available IOC frameworks for Flex, have a look at the sample code examples and the source code here gives good idea to structure your code.
SpringActionscript Cairngorm Extension
Have a look the tutorial explaining that how you can integrate springactionscript with cairngorm.
If we talk about the dependencies and different mappings in Cairngorm, what we need is:
- Event name and command mapping in front controller:define it in context file
- Command needs models: inject it through context configuration file
- Command needs delegate: define and inject through context file
- Delete needs service: define it in context file, helps in testing to define the mock objects
- Services and Amf channel configurations: configure it in context file
I am planning to cover all this with a sample example in the coming posts (will be too much to put everything here).
Cairngorm UM (UniversalMind) Extension
Have a look at Home page for list of add-ons provided by flexcairngorm.
Specially the one I like is the view notification implementation. You can either use the same extension or have a look at the implementation that how it is done and make changes in the base command and event classes to have the similar approach.
I will be posting soon the different approaches for the view notification and what all changes you need to do.
Have a look at ideas suggested by Marcin at the page and see how it fits in your case. Haven’t explored what this guy has suggested but feel free to explore more yourself.
Stay tuned for the sample code examples on how to use these frameworks to solve specific problems. I am planning to cover sample code for SpringActionscript cairngorm extension integration and custom implementation of UM extension for view notifications.