robotlegs/robotlegs-framework — pull request #84 by weltraumpirat (2012-06-10 22:29:16+00:00)
Title: Fix for issue #83

First of: I really like what you've done with the new RobotLegs, and I have already been using it heavily on an important project. You guys are doing a great job!

Anyway, because I kind of took a leap of faith with this, I desperately needed a solution for the problem I reported yesterday... and I found one easily enough: Separate the creation of Commands from their execution, and remove the event mappings in time to prevent the "cascading" effect.

Now while at it, I noticed that EventCommandTrigger violated the Single Responsibility Principle, and so I refactored the whole shebang into three separate classes, each one taking care of one responsibility:

1. Manage ICommandMappings and handle events => still in *EventCommandTrigger*
2. Create Commands from mappings => moved to *EventCommandFactory*
3. Map event injections and execute applicable commands => moved to *EventCommandExecutor*

The additional classes don't appear anywhere but in the context of EventCommandTrigger, and all the original unit tests still pass, so I don't think it is necessary to add or modify tests or create additional interfaces.

I couldn't import the prettyPrint settings into my FDT project, though, and so I took my own - sorry if that messed things up. Otherwise, I adapted commenting style where it seemed useful (I usually try not to write comments at all), and got rid of redundant ones after refactoring.

The code should be pretty much self-explanatory now, but please contact me any time, if anything is unclear.

I honestly enjoy working with RL2 a lot - if you deem this humble contribution in any way worth merging, and/or if you need any help with future development, you've made a happy user even happier :)

Thank you,

weltraumpirat