Manually Execute Commands

mbarjawi's Avatar

mbarjawi

03 Apr, 2013 07:22 PM

Hello,

Is there a way to manually execute a command..??

I am trying to work on a bootstrap tool for my application... I want to add command names to the tool, and then the tool should execute them in sequence.

One option I thought I have is to create a single signal inside the tool itself. This signal is attached to the current command to be executed, and then the signal is just dispatched. The command also knows about another Signal to dispatch once done. This way, I can start the next command after the previous one is done. However, I faced problems when remapping the trigger Signal to the next command, it keeps telling me that I am overriding a mapping.. even though I am explicitly un-mapping it but it is not working.

So the only option is that in the application itself, when creating the commands, I need to create a two signals for each command, a trigger signal and a notification signal. However, I felt this is too much, unnecessary, and defies the purpose of the tool as it should take care of everything instead of requiring outside work to be done in order for the tool to function properly.

Thanks for all the help,
MBarjawi

  1. Support Staff 1 Posted by creynders on 04 Apr, 2013 01:35 PM

    creynders's Avatar

    Hi mbarjawi,

    We're in the process of rewriting the command center, and direct command execution is definitely one of the features we're putting in.

    Maybe I didn't understand the problem fully, but can't you map the commands you want to have executed in sequence to the dedicated signal? Normally they're called in order.
    Or is this an async process?

    However, I faced problems when remapping the trigger Signal to the next command, it keeps telling me that I am overriding a mapping.. even though I am explicitly un-mapping it but it is not working.

    I suppose the unmapping happens in the executed command, right? I seem to remember this wasn't fixed yet in the current implementation of the signalCommandMap, but it definitely will be.
    Anyway, it's only a warning, nothing will explode, so you can safely ignore the warning until we've got the command center finished and the signalcommandmap updated.

  2. 2 Posted by mbarjawi on 04 Apr, 2013 03:27 PM

    mbarjawi's Avatar

    We're in the process of rewriting the command center, and direct command execution is definitely one of the features we're putting in.

    That's great!!... looking forward for it.

    Maybe I didn't understand the problem fully, but can't you map the commands you want to have executed in sequence to the dedicated signal? Normally they're called in order. Or is this an async process?

    Originally, my plan is to start a bootstrap extension now with the basic features that I need right away, and continue to develop it whenever I need more features in it later on.

    So the current need for my software is to call the configuration commands in sequence. I didn't know that I can map multiple commands to the same signal... thanks for sharing the information. Which brings me to the question: is there a documentation for RL2 that explains all of its features...

    I suppose the unmapping happens in the executed command, right? right

    Anyway, it's only a warning, nothing will explode

    You are right... however, I have then to modify the MVCSBundle and remove the VigilanceExtension which keeps giving errors for warnings. I didn't want to change anything in RL2's original code... but I guess its a temporary solution until things are fixed.

    Thanks for all the efforts you guys are doing. Thanks for Robotlegs, the best toolkit I've seen so far. I wish I can help in it one way or another.

  3. Support Staff 3 Posted by creynders on 05 Apr, 2013 05:30 AM

    creynders's Avatar

    So the current need for my software is to call the configuration commands in sequence.

    If I'm not mistaken that's what the config classes are meant for to setup the wiring and configuration. Or are you talking about creating an async bootstrapping sequence that loads configuration data from several sources?

  4. 4 Posted by mbarjawi on 06 Apr, 2013 04:02 AM

    mbarjawi's Avatar

    If I'm not mistaken that's what the config classes are meant for to setup the wiring and configuration.

    Do you mean just a plain IConfig class that has all the configuration inside it?

    I don't remember exactly where, but I saw in one example online that each group of configurations are grouped into commands... for example, all signalCommandMap configurations (the actions) are grouped into ConfigureActionsCommand, all behaviors are grouped in ConfigureBehaviorsCommand...etc... and I thought that this looks a bit more organized in stead of having a long list of all configurations in one single file. This might not be the best way of doing it... and I am not aware of any disadvantages of this way of doing things.

    So basically what I ended up doing now is something like this:

    public class MyConfig implements IConfig
    {
        [Inject]
        public var injector:Injector;
    
        [Inject]
        public var signalCommandMap:ISignalCommandMap;
    
        public function configure():void
        {
            signalCommandMap.map( StartBootstrap, true ).toCommand( ConfigureActionsCommand );
            signalCommandMap.map( StartBootstrap, true ).toCommand( ConfigureBehaviorsCommand );
            signalCommandMap.map( StartBootstrap, true ).toCommand( ConfigureModelsCommand );
            signalCommandMap.map( StartBootstrap, true ).toCommand( ConfigureServicesCommand );
    
            ISignal( injector.getInstance( StartBootstrap ) ).dispatch();
        }
    }
    

    I'd love to hear an expert's opinion on this way of bootstrapping things. So please don't hesitate to let me know what you think.

    I definitely want in the end to have a bootstrap class that handles even async bootstrapping and handles errors and other kinds of things... however, at this stage I figured this bootstrap class will take a long time to build... and I am in the middle of a big project.

    Thanks,

  5. Support Staff 5 Posted by creynders on 06 Apr, 2013 03:15 PM

    creynders's Avatar

    Sorry, I didn't mean to imply yours is a wrong or worse approach. Just that you can do it with config classes if you want. You can pass multiple config classes to the method:

    context.configure( ActionsConfig, BehavioursConfig, TiersConfig);
    //and nest them
    //TiersConfig.as
    [Inject]
    public var context:IContext;
    
    context.configure(ModelsConfig, ServicesConfig, ControllersConfig, ViewsConfig);
    
  6. Support Staff 6 Posted by Shaun Smith on 06 Apr, 2013 05:41 PM

    Shaun Smith's Avatar

    There wasn't any official configuration mechanism in RL1 so the convention was to use Commands to split up configuration.

    RL2, on the other hand, has a built-in configuration mechanism, which is now the preferred way to split things up.

  7. 7 Posted by mbarjawi on 07 Apr, 2013 03:55 PM

    mbarjawi's Avatar

    You are right... it seems more logical to place them in configuration files instead of commands.

    Thanks for all your replies and all the help.

  8. mbarjawi closed this discussion on 07 Apr, 2013 03:55 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac