Announcement Announcement Module
No announcement yet.
cairngorm commands inheritance chain Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • cairngorm commands inheritance chain

    Hi I ran into a problem while trying to shift my cairngorm based app to spring AS.

    I use inheritance in my commands which solves a number of problems. assuming each of my commands reference a relevant model and service. I have hundreds of commands in my application grouped under dozens different features, each feature has a different model\service. I use a base command class in order to eliminate the need to state dependencies on each command, in the base command I declare and set the service and model. here's a sample from the login feature:

    public class BaseLoginCommand implements Responder, Command
    		public var service:LoginServiceLocator;
    		public var model:LoginModelLocator;
                    public function BaseLoginCommand()
                           //get instances
                           LoginService = LoginServiceLocator.getInstance();
                           model = LoginModelLocator.getInstance();
    next I will have

    public class LoginCommand extneds BaseLoginCommand 
    		public override function execute(event:CairngormEvent):void
                         //reference the entities from the super class
    My current problem is that CairngormFrontController creates an empty instance of LoginCommand it would not inject the model or service. I've looked into the frameworks code and would be happy to assist in solving this issue. As far as I can see I will need to reference the application context and request a new instance LoginCommand, is this possible or does springAS only includes support for creation of singletons.

    I would be happy to hear peoples opinions regarding this,

    Last edited by liorbb; Apr 15th, 2009, 03:01 PM.

  • #2
    sorry for the very late reply...

    Hey there,

    sorry for the late reply, I keep forgetting to check the forums to see if I can answer any questions, sorry...
    But what you need to do is take a look at is the ICommandFactory interface, you can add instances of these to the CairngormFrontController to configure your commands.

    Read through the cairngorm extension docs at for the lowdown:
    Cairngorm extensions at

    I just wrote a blogpost about how to configure cairngorm with a convention based approach, it might not be the way to go for an application of several hundred of commands, but have a look anyways I suppose:

    Hope this helps, good luck,



    • #3
      Thanks for clearing this issue Roland, I had a feeling I was missing something. I also liked your autowiring solution, although I tend not to use autowiring.

      Recently I wrote a short tutorial on this subject while exploring Spring AS, I now changed it slightly after reading the article you linked to.



      • #4
        Glad to help Lior, and I had actually read your blogpost a while ago, nice to see you sharing your spring AS endeavors with the rest of the world, thanx

        As I stated in my post, the convention based autowiring might not always be the best idea from a clarity perspective in a really large application.

        A really large application configuration file might eventually become an issue though, its very much possible that the XML grows to be 50 or 100k and in a web context this might become an issue, that's why I offered an alternate approach.

        I guess the nicest thing about the combination of cairngorm and springactionscript is that you can make your own choice, which is always great