How do I configure the EventBus?

That depends on why you are using the EventBus. If you are using the EventBus for a Swing application, then no configuration is necessary. Just start using the static methods in org.bushe.swing.event.EventBus to subscribe to classes and publish instances. If you are using the EventBus for general purpose Java (non-Swing), then you need to first associate a name with an EventService implementation in the EventServiceLocator. The ThreadSafeEventService is an EventService implementation appropriate for general usage. See Getting Started for details and examples.

[top]

It's not working! What's the problem?

If you are publishing and subscribing on the EventBus and your subscribers are not being notified it's almost assuredly that your subscriber has been garbage collected since subscriptions are made weakly by default. To test the theory, replace EventBus.subscribe(theClass, theSubscriber); with EventBus.subscribeStrongly(theClass, theSubscriber);.

Enabling logging if you are still having problems. The EventBus will use Apache log4j if its present, otherwise it uses java.util.logging. To see the logging, turn DEBUG level logging on (or TRACE for a lot of detail) by using the class of the EventService implemention(s) in use, which by default is org.bushe.swing.event.SwingEventService.

[top]