Package org.refcodes.eventbus
GenericEventBus
is the (virtual) machine wide manager for event
handling. It implements a publish/subscribe mechanism.
"... lately some colleagues and me were reasoning on how to do client-side (Browser, JavaScript) communication between web-page components ... decoupled ... in general I recommend taking a look at an event-bus (aka page-bus), with Java why not take a look at the refcodes-eventbus? ... the following “equation” came to mind … simply speaking, the equation Observer pattern + Publish–subscribe pattern = Message broker solves to refcodes-eventbus ..."
Lightweight message broker = event-bus?
A lightweight Message broker can be a good solution for requirements doing in-JVM (Java Virtual Machine) communication as of:Signaling events to some event-listener … Subscribing your event-listener for some specific events … Publishing events merely to interested event-listeners … Strongly decoupling the publisher and the subscriber … Considering privacy issues (no simple broadcast) …
In the article refcodes-eventbus: Observer + Publish–subscribe = Message broker I describe the refcodes-eventbus accompanied with a plain simple example on how to use it.
The refcodes-eventbus artifact makes use of the refcodes-matcher framework for defining the criteria on when to deliver an event to an event-listener. It also sets on top of the refcodes-observer framework regarding issues around the Observer pattern ... See also "http://www.refcodes.org/blog/publish_subscribe_observe_event-bus"
-
ClassDescriptionAbstractEventBus<E extends org.refcodes.observer.GenericEvent<?>,
O extends org.refcodes.observer.Observer<E>, MATCH extends org.refcodes.observer.EventMatcher<E>, META extends org.refcodes.mixin.EventMetaData, H> The Class AbstractEventBus.TheDispatchStrategy
defines how child events are published within a parent event publish cycle.Provides an accessor for aDispatchStrategy
property.Provides a mutator for aDispatchStrategy
property.Provides aDispatchStrategy
property.Ready to implement vanilla plainGenericEventBus
specialization.Specialization of theGenericEventBusEvent
to be used with theEventBus
.Intuitive Meta-Class for theMetaDataActionEventBuilderImpl
as used by theEventBusImpl
.Intuitive Meta-Class for theMetaDataActionEventImpl
as used by theEventBusImpl
.A convenience definition of anEventMatcher
for the ready to use out of the boxEventBusImpl
implementation of the genericGenericEventBus
definition.TheEventBusImpl
defines a predefinedGenericEventBus
tailored to use theMetaDataActionEvent
as event type to use.EventBusObservable<E extends org.refcodes.observer.GenericEvent<?>,O extends org.refcodes.observer.Observer<E>, MATCH extends org.refcodes.observer.EventMatcher<E>, H> A convenience definition of anObserver
for the ready to use out of the boxEventBusImpl
implementation of the genericGenericEventBus
definition.EventBusPublisher<E extends org.refcodes.observer.GenericEvent<?>>TheEventBusPublisher
defines methods to publish events as ofPublisher.publishEvent(GenericEvent)
and to test beforehand if there is a consumer for a given event as ofMatchable.isMatching(Object)
.Declarative syntactic sugar which may be statically imported in order to allow declarative definitions for theEventBusEventMatcher
elements.GenericEventBus<E extends org.refcodes.observer.GenericEvent<?>,O extends org.refcodes.observer.Observer<E>, MATCH extends org.refcodes.observer.EventMatcher<E>, META extends org.refcodes.mixin.EventMetaData, H> TheGenericEventBus
is the (virtual) machine wide manager forGenericActionEvent
handling.GenericEventBusEvent<A,META extends org.refcodes.mixin.EventMetaData, SRC extends GenericEventBus<?, ?, ?, ?, ?>> Intuitive Meta-Interface for theGenericActionMetaDataEvent
as used by theEventBusImpl
.GenericEventBusEvent.GenericEventBusEventBuilder<A,META extends org.refcodes.mixin.EventMetaData, SRC extends GenericEventBus<?, ?, ?, ?, ?>, B extends GenericEventBusEvent.GenericEventBusEventBuilder<A, META, SRC, B>> Intuitive Meta-Interface for theGenericEventBusEvent.GenericEventBusEventBuilder
as used by theGenericEventBus
.