public class SyncSubscribersGatekeeper
extends java.lang.Object
EventBusImpl. This determines whether a particular
subscriber annotated with Subscribe.syncIfAllowed() as true is
actually allowed to be synchronous. ALLOW_SYNC_SUBSCRIBERS is true SYNC_SUBSCRIBERS_WHITELIST_JSON exists, is non empty
and contains this subscriber.SYNC_SUBSCRIBERS_WHITELIST_JSON with a json of the following format:
{
"[Fully qualified class name of the subscriber class]": 0 or more fully qualified class name of the events,
}
{
"com.foo.bar.MyAllSubscriber": [], // Signifies all subscriber methods in this class will be sync, if configured so by setting Subscribe.syncIfAllowed() as true.
"com.foo.bar.MySubscriber": ["com.foo.bar.EventOne", "com.foo.bar.EventTwo"], // Signifies only subscrber of events EventOne & EventTwo in this class will be sync, if configured so by setting Subscribe.syncIfAllowed() as true.
"com.foo.bar.MyAnotherSubscriber": ["com.foo.bar.Event3", "com.foo.bar.Event4"]
}
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ALLOW_ALL_EVENTS |
static java.lang.String |
ALLOW_SYNC_SUBSCRIBERS |
static com.google.common.collect.SetMultimap<java.lang.String,java.lang.String> |
EMPTY_WHITELIST |
static java.lang.String |
SYNC_SUBSCRIBERS_WHITELIST_JSON
Property to define a whitelist of subscribers which are allowed to be synchronous.
|
| Constructor and Description |
|---|
SyncSubscribersGatekeeper() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isSyncSubscriber(SubscriberConfigProvider.SubscriberConfig subscribe,
java.lang.Class eventClass,
java.lang.Class subscriberClass)
Deduce whether the subscriber favors synchronous event consumption.
|
public static final java.lang.String ALLOW_SYNC_SUBSCRIBERS
public static final java.lang.String SYNC_SUBSCRIBERS_WHITELIST_JSON
SyncSubscribersGatekeeper javadocs for details of the format of this property.public static final com.google.common.collect.SetMultimap<java.lang.String,java.lang.String> EMPTY_WHITELIST
public static final java.lang.String ALLOW_ALL_EVENTS
public static boolean isSyncSubscriber(SubscriberConfigProvider.SubscriberConfig subscribe, java.lang.Class eventClass, java.lang.Class subscriberClass)
SyncSubscribersGatekeeper javadoc
for details of when will this be allowed.subscribe - The configuration for the subscriber in question.eventClass - Class of the event for which this check is to be done.subscriberClass - Class of the subscriber for which this check is to be done.true if the subscriber should be provided events synchronously.