EventBus

The EventBus is a simple but powerful publish/subscribe API with annotations that allows POJOs to communicate with each other anywhere in a JVM without having to refer to each other. EventBus subscriptions are based on class semantics and/or string (topic) matching. The EventBus is fit for general purpose usage and has extensions for UI development.

Why use the EventBus?

The publish/subscribe pattern is commonly used to decouple components, make testing easier, and program by contract. It replaces the tight coupling introduced by explicit listeners with a flexible loosely coupled design. The EventBus is production ready and used in many applications, including financial UIs, scientific simulations, and the most popular Java desktop application, Limewire. The EventBus is well tested and has very good documentation.

The EventBus is not a JMS competitor. The EventBus is for pub/sub communication within a VM. The EventBus is often used by JMS listeners to route events internally once they are pulled off the JMS queue or topic.

Project Status

EventBus 1.x is stable, well tested, well documented and suitable for general purpose Java applications and UIs, including Swing, SWT, and Apache Pivot.

EventBus 2.x is a work in progress. It will use the newly acquired org.eventbus package and will be extended to other UI toolkits and RIAs such as Javascript, GWT, and Flex. Update 3/2013: The EventBus has gone stale and is unlikely to be extended to other platforms. Suitable, though more primitive, replacements can be found for GWT (GWT EventBus), Javascript (TIBCO PageBus - an OpenAjax Hub implementation) and Flex (Parsley's Messaging)

Latest News

  • 26-Feb-2010 New pub/sub patterns article on using Apache Pivot and the EventBus

    The article demonstrates common UI pub/sub patterns using Apache Pivot. No matter what UI technology you use, this article will show you what the EventBus can do for your UIs, and you'll learn about Apache Pivot along the way.

  • 12-Feb-2010 EventBus 1.4 Released. EventBus 1.4 adds:
    • Runtime Subscriber annotation for dynamic subscriptions, thanks to Mario Aquino from Limewire for the patch. A good use case for a dynamic subscription is a chat client. The chat window will not know whose messages to subscribe to until runtime. Instead of subscribing to a String known at compile time, an Annotation (or API) can define the method that will determine a subscription string at runtime.
    • PublicationStatus enum so that an event Object implementing PublicationStatusTracker can report whether the event was vetoed, published, is being processed, etc.
    • @VetoSubscriber annotation to take the boilerplate out of coding veto subscribers.
    • Added AnnotationProcessor.unprocess(this) to auto-unsubscribe all the subscriptions than the annotationed object created.
    • The ContainerEventServiceRegistrar called updateContainerEventService too often when tracking changes to the parent of a component subscribed to it's container's EventService.
    • Thorough spelling check from tournament Scrabble player Callum Bushe. Thanks to Cal for correcting the dozen of variations of "subscribe" in the code base, and much more. Cal used IntelliJ IDEA 9 code spellchecker, courtesy of IntelliJ's license for Open Source projects, thanks to JetBrains as well.

    More News