Class ApplicationBusSugar
java.lang.Object
org.refcodes.eventbus.ext.application.ApplicationBusSugar
Declarative syntactic sugar which may be statically imported in order to
allow declarative definitions for the
ApplicationEventMatcher
elements.-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
protected static class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <A> ApplicationEventMatcher
actionEqualWith
(A aAction) Factory method to create an "EQUAL WITH" matcher for the given action compared with the action stored in theEventMetaData
.static ApplicationEventMatcher
aliasEqualWith
(String aAlias) Factory method to create an "EQUAL WITH" matcher for the given name compared with the name stored in theEventMetaData
.static ApplicationEventMatcher
and
(ApplicationEventMatcher... aEventMatchers) Factory method to create an "AND" matcher for the given matchers.static ApplicationBus
static ApplicationBus
applicationBus
(boolean isDaemon) static ApplicationBusEvent
applicationBusEvent
(Class<?> aPublisherType, ApplicationBus aSource) Constructs an event with predefined values for the according properties retrieved from the caller's class.static ApplicationBusEvent
applicationBusEvent
(Enum<?> aAction, Class<?> aPublisherType, ApplicationBus aSource) Constructs an event with predefined values for the according properties retrieved from the caller's class.static ApplicationBusEvent
applicationBusEvent
(Enum<?> aAction, String aAlias, String aGroup, String aChannel, String aUid, Class<?> aPublisherType, ApplicationBus aSource) Constructs an event with the given values for the according properties.static ApplicationBusEvent
applicationBusEvent
(Enum<?> aAction, String aChannel, ApplicationBus aSource) Constructs an event with predefined values for the according properties retrieved from the caller's class.static ApplicationBusEvent
applicationBusEvent
(Enum<?> aAction, ApplicationBus aSource) Constructs an event with the given Meta-Data.static ApplicationBusEvent
applicationBusEvent
(Enum<?> aAction, org.refcodes.mixin.EventMetaData aEventMetaData, ApplicationBus aSource) Constructs an event with the given Meta-Data.static ApplicationBusEvent
applicationBusEvent
(String aAlias, String aGroup, String aChannel, String aUid, Class<?> aPublisherType, ApplicationBus aSource) Constructs an event with the given values for the according properties.static ApplicationBusEvent
applicationBusEvent
(String aChannel, ApplicationBus aSource) Constructs an event with predefined values for the according properties retrieved from the caller's class.static ApplicationBusEvent
applicationBusEvent
(ApplicationBus aSource) Constructs an event with the given Meta-Data.static ApplicationBusEvent
applicationBusEvent
(org.refcodes.mixin.EventMetaData aEventMetaData, ApplicationBus aSource) Constructs an event with the given Meta-Data.static ApplicationBus
Constructs theApplicationBus
with theDispatchStrategy.ASYNC
when publishing events: Same as theDispatchStrategy.SEQUENTIAL
approach with the difference that the sequential dispatch process is done asynchronously, freeing your parent's thread immediately after publishing your parent event.static ApplicationBus
asyncDispatchBus
(boolean isDaemon) Constructs theApplicationBus
with theDispatchStrategy.ASYNC
when publishing events: Same as theDispatchStrategy.SEQUENTIAL
approach with the difference that the sequential dispatch process is done asynchronously, freeing your parent's thread immediately after publishing your parent event.static ApplicationBus
Constructs theApplicationBus
with theDispatchStrategy.CASCADE
when publishing events: The parent (invoker) thread is used to publish the parent's event to all matching observers (and is blocked till done).static ApplicationBus
cascadeDispatchBus
(boolean isDaemon) Constructs theApplicationBus
with theDispatchStrategy.CASCADE
when publishing events: The parent (invoker) thread is used to publish the parent's event to all matching observers (and is blocked till done).static ApplicationEventMatcher
catchAll()
Catches all events, no matching is done.static ApplicationEventMatcher
Catches no event, no matching is done.static ApplicationEventMatcher
channelEqualWith
(String aChannel) Factory method to create an "EQUAL WITH" matcher for the given channel compared with the channel stored in theEventMetaData
.static ApplicationEventMatcher
groupEqualWith
(String aGroup) Factory method to create an "EQUAL WITH" matcher for the given group compared with the group stored in theEventMetaData
.static ApplicationEventMatcher
isAssignableFrom
(Class<?> aEventType) Factory method to create an event matcher by event type.static ApplicationEventMatcher
or
(ApplicationEventMatcher... aEventMatchers) Factory method to create an "OR" matcher for the given matchers.static ApplicationBus
Constructs theApplicationBus
with theDispatchStrategy.PARALLEL
when publishing events: Each matching observer is invoked in its own thread.static ApplicationBus
parallelDispatchBus
(boolean isDaemon) Constructs theApplicationBus
with theDispatchStrategy.PARALLEL
when publishing events: Each matching observer is invoked in its own thread.static <PT> ApplicationEventMatcher
publisherIsAssignableFrom
(Class<? extends PT> aPublisherType) Factory method to create an event matcher by event publisher type.static ApplicationBus
Constructs theApplicationBus
with theDispatchStrategy.SEQUENTIAL
when publishing events: The parent (invoker) thread is used to publish the parent's event as well as the child events published by the matching observers of the parent event (and so on, in case them useDispatchStrategy.SEQUENTIAL
as well).static ApplicationBus
sequentialDispatchBus
(boolean isDaemon) Constructs theApplicationBus
with theDispatchStrategy.SEQUENTIAL
when publishing events: The parent (invoker) thread is used to publish the parent's event as well as the child events published by the matching observers of the parent event (and so on, in case them useDispatchStrategy.SEQUENTIAL
as well).static ApplicationEventMatcher
uidIdEqualWith
(String aUid) Factory method to create an "EQUAL WITH" matcher for the given UID compared with the UID stored in theEventMetaData
.
-
Constructor Details
-
ApplicationBusSugar
public ApplicationBusSugar()
-
-
Method Details
-
applicationBus
- Returns:
- The accordingly configured
ApplicationBus
.
-
applicationBus
- Parameters:
isDaemon
- True when to create daemon dispatchThread
instances (shutdown upon last applicationThread
shutdown), else applicationThread
instances are created for dispatch.- Returns:
- The accordingly configured
ApplicationBus
.
-
parallelDispatchBus
Constructs theApplicationBus
with theDispatchStrategy.PARALLEL
when publishing events: Each matching observer is invoked in its own thread. No observer can block your invoking thread.- Returns:
- The accordingly configured
ApplicationBus
.
-
parallelDispatchBus
Constructs theApplicationBus
with theDispatchStrategy.PARALLEL
when publishing events: Each matching observer is invoked in its own thread. No observer can block your invoking thread.- Parameters:
isDaemon
- True when to create daemon dispatchThread
instances (shutdown upon last applicationThread
shutdown), else applicationThread
instances are created for dispatch.- Returns:
- The accordingly configured
ApplicationBus
.
-
sequentialDispatchBus
Constructs theApplicationBus
with theDispatchStrategy.SEQUENTIAL
when publishing events: The parent (invoker) thread is used to publish the parent's event as well as the child events published by the matching observers of the parent event (and so on, in case them useDispatchStrategy.SEQUENTIAL
as well). Any observer (directly or indirectly) invoked by your invoking thread can block your invoking thread.- Returns:
- The accordingly configured
ApplicationBus
.
-
sequentialDispatchBus
Constructs theApplicationBus
with theDispatchStrategy.SEQUENTIAL
when publishing events: The parent (invoker) thread is used to publish the parent's event as well as the child events published by the matching observers of the parent event (and so on, in case them useDispatchStrategy.SEQUENTIAL
as well). Any observer (directly or indirectly) invoked by your invoking thread can block your invoking thread.- Parameters:
isDaemon
- True when to create daemon dispatchThread
instances (shutdown upon last applicationThread
shutdown), else applicationThread
instances are created for dispatch.- Returns:
- The accordingly configured
ApplicationBus
.
-
asyncDispatchBus
Constructs theApplicationBus
with theDispatchStrategy.ASYNC
when publishing events: Same as theDispatchStrategy.SEQUENTIAL
approach with the difference that the sequential dispatch process is done asynchronously, freeing your parent's thread immediately after publishing your parent event. Exactly one extra thread is created to kick off the asynchronous way of doing a sequential dispatch. Any observer (directly or indirectly) invoked by the "asynchronous" thread can block any other observer in that chain, but not your invoking thread.- Returns:
- The accordingly configured
ApplicationBus
.
-
asyncDispatchBus
Constructs theApplicationBus
with theDispatchStrategy.ASYNC
when publishing events: Same as theDispatchStrategy.SEQUENTIAL
approach with the difference that the sequential dispatch process is done asynchronously, freeing your parent's thread immediately after publishing your parent event. Exactly one extra thread is created to kick off the asynchronous way of doing a sequential dispatch. Any observer (directly or indirectly) invoked by the "asynchronous" thread can block any other observer in that chain, but not your invoking thread.- Parameters:
isDaemon
- True when to create daemon dispatchThread
instances (shutdown upon last applicationThread
shutdown), else applicationThread
instances are created for dispatch.- Returns:
- The accordingly configured
ApplicationBus
.
-
cascadeDispatchBus
Constructs theApplicationBus
with theDispatchStrategy.CASCADE
when publishing events: The parent (invoker) thread is used to publish the parent's event to all matching observers (and is blocked till done). Child events published by the matching observers invoked with the parent's event are queued until the parent's thread finished dispatching the parent's event. The queued child events then are published in their own separate threads, now considered being parent events with their according parent threads, to all matching observers (dispatching as described above). TheDispatchStrategy.CASCADE
strategy is useful when publishing lifecycle or bootstrapping events to make sure, that any observer was notified before publishing post-lifecycle actions. Observers directly invoked by your invoking thread can block your invoking thread and indirectly invoked observers called by your directly invoked observers using theDispatchStrategy.SEQUENTIAL
strategy for publishing their events.- Returns:
- The accordingly configured
ApplicationBus
.
-
cascadeDispatchBus
Constructs theApplicationBus
with theDispatchStrategy.CASCADE
when publishing events: The parent (invoker) thread is used to publish the parent's event to all matching observers (and is blocked till done). Child events published by the matching observers invoked with the parent's event are queued until the parent's thread finished dispatching the parent's event. The queued child events then are published in their own separate threads, now considered being parent events with their according parent threads, to all matching observers (dispatching as described above). TheDispatchStrategy.CASCADE
strategy is useful when publishing lifecycle or bootstrapping events to make sure, that any observer was notified before publishing post-lifecycle actions. Observers directly invoked by your invoking thread can block your invoking thread and indirectly invoked observers called by your directly invoked observers using theDispatchStrategy.SEQUENTIAL
strategy for publishing their events.- Parameters:
isDaemon
- True when to create daemon dispatchThread
instances (shutdown upon last applicationThread
shutdown), else applicationThread
instances are created for dispatch.- Returns:
- The accordingly configured
ApplicationBus
.
-
applicationBusEvent
public static ApplicationBusEvent applicationBusEvent(Class<?> aPublisherType, ApplicationBus aSource) Constructs an event with predefined values for the according properties retrieved from the caller's class.- Parameters:
aPublisherType
- The type of the event publisher.aSource
- The source from which this event originated.- Returns:
- The accordingly created
ApplicationBusEvent
instance.
-
applicationBusEvent
public static ApplicationBusEvent applicationBusEvent(Enum<?> aAction, Class<?> aPublisherType, ApplicationBus aSource) Constructs an event with predefined values for the according properties retrieved from the caller's class.- Parameters:
aAction
- The action which this represents.aPublisherType
- The type of the event publisher.aSource
- The source from which this event originated.- Returns:
- The accordingly created
ApplicationBusEvent
instance.
-
applicationBusEvent
public static ApplicationBusEvent applicationBusEvent(Enum<?> aAction, org.refcodes.mixin.EventMetaData aEventMetaData, ApplicationBus aSource) Constructs an event with the given Meta-Data.- Parameters:
aAction
- The action which this represents.aEventMetaData
- The Meta-Data to be supplied by the event.aSource
- The source from which this event originated.- Returns:
- The accordingly created
ApplicationBusEvent
instance.
-
applicationBusEvent
Constructs an event with the given Meta-Data.- Parameters:
aAction
- The action which this represents.aSource
- The source from which this event originated.- Returns:
- The accordingly created
ApplicationBusEvent
instance.
-
applicationBusEvent
public static ApplicationBusEvent applicationBusEvent(Enum<?> aAction, String aChannel, ApplicationBus aSource) Constructs an event with predefined values for the according properties retrieved from the caller's class.- Parameters:
aAction
- The action which this represents.aChannel
- The channel name on which the event is receivable.aSource
- The source from which this event originated.- Returns:
- The accordingly created
ApplicationBusEvent
instance.
-
applicationBusEvent
public static ApplicationBusEvent applicationBusEvent(Enum<?> aAction, String aAlias, String aGroup, String aChannel, String aUid, Class<?> aPublisherType, ApplicationBus aSource) Constructs an event with the given values for the according properties.- Parameters:
aAction
- The action which this represents.aAlias
- The alias property.aGroup
- The group property.aChannel
- The channel property.aUid
- The UID (Universal-TID) property.aPublisherType
- The type of the event publisher.aSource
- The source from which this event originated.- Returns:
- The accordingly created
ApplicationBusEvent
instance.
-
applicationBusEvent
public static ApplicationBusEvent applicationBusEvent(org.refcodes.mixin.EventMetaData aEventMetaData, ApplicationBus aSource) Constructs an event with the given Meta-Data.- Parameters:
aEventMetaData
- The Meta-Data to be supplied by the event.aSource
- The source from which this event originated.- Returns:
- The accordingly created
ApplicationBusEvent
instance.
-
applicationBusEvent
Constructs an event with the given Meta-Data.- Parameters:
aSource
- The source from which this event originated.- Returns:
- The accordingly created
ApplicationBusEvent
instance.
-
applicationBusEvent
Constructs an event with predefined values for the according properties retrieved from the caller's class.- Parameters:
aChannel
- The channel name on which the event is receivable.aSource
- The source from which this event originated.- Returns:
- The accordingly created
ApplicationBusEvent
instance.
-
applicationBusEvent
public static ApplicationBusEvent applicationBusEvent(String aAlias, String aGroup, String aChannel, String aUid, Class<?> aPublisherType, ApplicationBus aSource) Constructs an event with the given values for the according properties.- Parameters:
aAlias
- The alias property.aGroup
- The group property.aChannel
- The channel property.aUid
- The UID (Universal-TID) property.aPublisherType
- The type of the event publisher.aSource
- The source from which this event originated.- Returns:
- The accordingly created
ApplicationBusEvent
instance.
-
catchAll
Catches all events, no matching is done.- Returns:
- The "catch-all"
ApplicationEventMatcher
.
-
catchNone
Catches no event, no matching is done.- Returns:
- The "catch-none"
ApplicationEventMatcher
.
-
isAssignableFrom
Factory method to create an event matcher by event type.- Parameters:
aEventType
- The event type to be matched by this matcher.- Returns:
- An event matcher by event type.
-
publisherIsAssignableFrom
public static <PT> ApplicationEventMatcher publisherIsAssignableFrom(Class<? extends PT> aPublisherType) Factory method to create an event matcher by event publisher type.- Type Parameters:
PT
- The publisher descriptor type- Parameters:
aPublisherType
- The event publisher type to be matched by this matcher.- Returns:
- An event matcher by event type.
-
or
Factory method to create an "OR" matcher for the given matchers.- Parameters:
aEventMatchers
- The matchers to be combined by an "OR".- Returns:
- An "OR" matcher.
-
and
Factory method to create an "AND" matcher for the given matchers.- Parameters:
aEventMatchers
- The matchers to be combined by an "AND".- Returns:
- An "AND" matcher.
-
aliasEqualWith
Factory method to create an "EQUAL WITH" matcher for the given name compared with the name stored in theEventMetaData
.- Parameters:
aAlias
- The name to be compared with aGenericMetaDataEvent
'sEventMetaData
's name property.- Returns:
- An "EQUAL WITH" matcher regarding the
GenericMetaDataEvent
's name property.
-
groupEqualWith
Factory method to create an "EQUAL WITH" matcher for the given group compared with the group stored in theEventMetaData
.- Parameters:
aGroup
- The group to be compared with aGenericMetaDataEvent
'sEventMetaData
's group property.- Returns:
- An "EQUAL WITH" matcher regarding the
GenericMetaDataEvent
's group property.
-
channelEqualWith
Factory method to create an "EQUAL WITH" matcher for the given channel compared with the channel stored in theEventMetaData
.- Parameters:
aChannel
- The channel to be compared with aGenericMetaDataEvent
'sEventMetaData
's channel property.- Returns:
- An "EQUAL WITH" matcher regarding the
GenericMetaDataEvent
's channel property.
-
uidIdEqualWith
Factory method to create an "EQUAL WITH" matcher for the given UID compared with the UID stored in theEventMetaData
.- Parameters:
aUid
- The UID to be compared with aGenericMetaDataEvent
'sEventMetaData
's UID property.- Returns:
- An "EQUAL WITH" matcher regarding the
GenericMetaDataEvent
's UID property.
-
actionEqualWith
Factory method to create an "EQUAL WITH" matcher for the given action compared with the action stored in theEventMetaData
.- Type Parameters:
A
- The type of the action stored in the event. CAUTION: The drawback of not using generic generic type declaration on a class level is no granted type safety, the advantage is the ease of use: Sub-classes can be used out of the box.- Parameters:
aAction
- The action to be compared with aGenericMetaDataEvent
'sEventMetaData
's action property.- Returns:
- An "EQUAL WITH" matcher regarding the
GenericActionEvent
's action property.
-