In the Python Robots API, there method robot.Robot.register_handler states
(correctly, I believe) that "Multiple handlers may be registered on a single
event type and are guaranteed to be called in order of registration." However,
in the Java Robots API, the only way I can find to define event handlers is to
override the appropriate method of AbstractRobot -- so I may only define one
event handler for any given event.
I would like some way to define multiple handlers for the same event in the
Java API, just as I can with register_handler in the Python API.
I realise that I could "multiplex" two event handlers into one just by running
one after the other, allowing me to do this. However, I cannot be so precise
about contexts and filters this way as I could in the Python API. For instance,
consider the following code in the Python API:
bot.register_handler(events.DocumentChanged, handler1, context=[ALL],
filter="specific_filter")
bot.register_handler(events.DocumentChanged, handler2, context=[SELF],
filter="general_filter")
I expect handler2 to be triggered much more often than handler1 (because the
filter is somehow more general), but that's okay because it requires in a
smaller context. If I were to try translating this into the Java API by just
running the two handlers one after another, I would be forced to set the
context to ALL, and to use the more general filter -- so now the handler is
triggered frequently, with the whole context.
Original issue reported on code.google.com by reiner.p...@gmail.com on 28 Dec 2010 at 9:30
Original issue reported on code.google.com by
reiner.p...@gmail.com
on 28 Dec 2010 at 9:30