2009/8/25 Joonas Pulakka <joonas.pulakka@iki.fi>
I'm trying to use EventBus (https://eventbus.dev.java.net/) from Jython. Sending events to the from Jython bus works as expected, they can be listened from my Java code. But subscribing to the bus from Jython is problematic. I'm trying this:

class Listener(EventTopicSubscriber):
    def onEvent(self, topic, object):
        print("got an event")

EventBus.subscribe("Topic", Listener)

It results in: TypeError: subscribe(): 1st arg can't be coerced to java.util.regex.Pattern, java.lang.reflect.Type, String, java.lang.Class

Ah, stupid mistake - I was just lacking a pair of parentheses, the constructor of "Listener" wasn't called. It's of course supposed to be:

EventBus.subscrive("Topic", Listener())

Which works like a dream! Anyway, the error message (from EventBus) was a bit misleading - there was nothing wrong with the 1st argument.

Best Regards,
Joonas