C - all feeds are for this message type.F - the subordinate feed type.public abstract class EMultiFeed<C extends EMessage,F extends net.sf.eBus.client.ESingleFeed> extends EFeed
EPublishFeed,
ESubscribeFeed, EReplyFeed, and
ERequestFeed), all for a single message class. The
multi-key feed keeps the subordinate feeds in the same state:
open, advertised/subscribed, or closed. The subordinate feeds
are configured with the same eBus client and callback methods.
This base class tracks all currently open subordinate feeds and the overall feed state.
| Modifier and Type | Class and Description |
|---|---|
protected static interface |
EMultiFeed.MultiFeedFactory<M extends EMultiFeed,C extends EMessage,F extends EFeed>
This interface is used by
EMultiFeed to
instantiate a new multi-key, sub-class feed. |
protected static interface |
EMultiFeed.SubordinateFeedFactory<R extends EObject,F extends net.sf.eBus.client.ESingleFeed>
This interface is used by
EMultiFeed to
instantiate a new subordinate feed for a multi-key feed. |
EFeed.AbstractClientTask, EFeed.FeedScope, EFeed.NotifyTask, EFeed.StatusTask<T extends IEFeed>| Modifier and Type | Field and Description |
|---|---|
protected ECondition |
mCondition
Use this condition to check if received message should be
forwarded to client.
|
protected Map<CharSequence,F> |
mFeeds
Contains the subordinate feeds currently opened by this
multi-key feed.
|
protected Class<? extends C> |
mMsgClass
All subordindate feeds apply to this message class.
|
static String |
MULTIFEED_SUBJECT
key() returns a message key with the subject
"__MULTIFEED__". |
protected static Logger |
sLogger
Logging subsystem interface.
|
mEClient, mFeedId, mFeedState, mInPlace, mIsActive, mScope, NO_CONDITION, NOTIFY_METHOD| Modifier | Constructor and Description |
|---|---|
protected |
EMultiFeed(EClient client,
Class<? extends C> msgClass,
EFeed.FeedScope scope,
ECondition condition,
Map<CharSequence,F> feeds)
Creates a new multiple key feed for the given eBus client,
message class, scope, and initial feeds.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAllFeeds(List<String> subjects)
Adds new feeds based on the configured message class and
the subjects list.
|
void |
addAllFeeds(Pattern query)
Adds new feeds for each of the subjects matching the given
query.
|
void |
addFeed(String subject)
Adds a new feed based on the configured message class and
the given subject.
|
void |
closeFeed(String subject)
Removes and closes the feed for the given message subject.
|
protected abstract F |
createFeed(EMessageKey key)
Returns a newly minted subordinate feed for the given
message key.
|
EFeedState |
feedState(String subject)
Returns the specified feed's state.
|
protected void |
inactivate()
Closes all currently open subordinate feeds and clears
the feeds map.
|
boolean |
isFeedUp()
Returns
true if all subordinate feeds are up and
false otherwise. |
EMessageKey |
key()
Returns a message key with
messageClass() as the
class and MULTIFEED_SUBJECT as the subject. |
List<EMessageKey> |
keys()
Returns the current subordinate feed message keys.
|
Class<? extends C> |
messageClass()
Returns the multi-key feed message class.
|
protected static <R extends EObject,C extends EMessage,F extends net.sf.eBus.client.ESingleFeed,M extends EMultiFeed<C,F>> |
openList(R client,
Class<? extends C> mc,
List<String> subjects,
EFeed.FeedScope scope,
ECondition condition,
EMultiFeed.SubordinateFeedFactory<R,F> subFactory,
EMultiFeed.MultiFeedFactory<M,C,F> multiFactory)
Returns a new, opened multi-key feed for the given
parameters.
|
protected static <R extends EObject,C extends EMessage,F extends net.sf.eBus.client.ESingleFeed,M extends EMultiFeed<C,F>> |
openQuery(R client,
Class<? extends C> mc,
Pattern query,
EFeed.FeedScope scope,
ECondition condition,
EMultiFeed.SubordinateFeedFactory<R,F> subFactory,
EMultiFeed.MultiFeedFactory<M,C,F> multiFactory)
Returns a new, opened multi-key feed for the given message
class and subject regular expression query.
|
protected abstract void |
putFeedInPlace(F feed)
Advertises/subscribes the given feed.
|
List<String> |
subjects()
Returns the current subordinate feed message subjects.
|
addAllKeys, addKey, checkScopes, clientId, close, defaultDispatcher, eClient, equals, feedId, feedState, findKeys, findKeys, findKeys, hashCode, inPlace, isActive, isOverridden, loadKeys, location, register, register, register, scope, shutdown, shutdown, shutdownAll, startup, startup, startupAll, storeKeys, storeKeys, storeKeys, toStringpublic static final String MULTIFEED_SUBJECT
key() returns a message key with the subject
"__MULTIFEED__".protected static final Logger sLogger
protected final Class<? extends C extends EMessage> mMsgClass
adding
new feeds to this multi-key feed.protected final ECondition mCondition
null if the subordinate feed does not support
message condition.protected final Map<CharSequence,F extends net.sf.eBus.client.ESingleFeed> mFeeds
EMessageKey.subject() to
the subordinate feed.protected EMultiFeed(EClient client, Class<? extends C> msgClass, EFeed.FeedScope scope, ECondition condition, Map<CharSequence,F> feeds)
client, msgClass,
scope, and (optionally) condition.client - connect this client to the subordinate feeds.msgClass - all feeds apply to this message class.scope - feed scope.feeds - initial subordinate feeds.condition - condition applied to all subordinate
feeds. Will be null for feeds which do not use a
condition.protected abstract F createFeed(EMessageKey key)
addFeed(String) to create a subordinate feed.key - create feed for this key.protected abstract void putFeedInPlace(F feed)
addFeed(String) to adverise/subscribe
the added feed.feed - feed to advertised/subscribed.protected final void inactivate()
inactivate in class EFeedpublic final Class<? extends C> messageClass()
added feeds are created with this
class.public final boolean isFeedUp()
true if all subordinate feeds are up and
false otherwise.public final EMessageKey key()
messageClass() as the
class and MULTIFEED_SUBJECT as the subject.public final EFeedState feedState(String subject)
If subject references an unknown feed or the feed
is not in place, then EFeedState.UNKNOWN is
returned.
subject - return the publish state for this message
subject.UNKNOWN if
subject does not reference a known feed.NullPointerException - if subject is null.IllegalArgumentException - if subject is empty.IllegalStateException - if this multi-key feed is closed.public final List<String> subjects()
IllegalStateException - if this multi-key feed is closed.public final List<EMessageKey> keys()
IllegalStateException - if this multi-key feed is closed.public final void addFeed(String subject)
subject in place.
The newly created feed references the same
client, message class,
scope and
(optional) condition as all the other
subordinate feeds in this multi-key feed. It will also use
the same callbacks as existing subordinate feeds.
subject - add key with this message subject.NullPointerException - if subject is null.IllegalArgumentException - if subject is empty.IllegalStateException - if this multi-key feed is closed.addAllFeeds(List),
addAllFeeds(Pattern),
closeFeed(String)public final void addAllFeeds(List<String> subjects)
subjects contains
feeds that already exist, the existing feed is neither
replaced or modified.
The newly created feeds reference the same
client, message class,
scope and
(optional) condition as all the other
subordinate feeds in this multi-key feed. They will also
use the same callbacks as existing subordinate feeds.
subjects - create new feeds for these subjects.NullPointerException - if subjects is null or contains a
null element.IllegalArgumentException - if subjects contains an empty string.IllegalStateException - if this multi-key feed is closed.addFeed(String),
addAllFeeds(Pattern),
closeFeed(String)public final void addAllFeeds(Pattern query)
query matches an existing feed
subject, then the existing feed is neither modified not
replaced. The new feeds are for this multi-key feed's
message class.query - find all subjects matching this query.NullPointerException - if query is null.IllegalStateException - if this multi-key feed is closed.addFeed(String),
addAllFeeds(List),
closeFeed(String)public final void closeFeed(String subject)
subject does not reference a
known subordinate feed.subject - remove and close the feed for this subject.NullPointerException - if subject is null.IllegalArgumentException - if subject is empty.IllegalStateException - if this multi-key feed is closed.addFeed(String)protected static <R extends EObject,C extends EMessage,F extends net.sf.eBus.client.ESingleFeed,M extends EMultiFeed<C,F>> M openList(R client, Class<? extends C> mc, List<String> subjects, EFeed.FeedScope scope, ECondition condition, EMultiFeed.SubordinateFeedFactory<R,F> subFactory, EMultiFeed.MultiFeedFactory<M,C,F> multiFactory)
R - eBus role used with this multi-key feed.C - feed based on this message class.F - subordinate feed class.M - multi-key feed class.client - application object interacting with the
feed.mc - feed message class.subjects - message subject list. May not contain
null or empty strings.scope - whether the feed supports local feeds,
remote feeds, or both.condition - the optional condition used by the
subordinate feed.subFactory - used to instantiate a new subordinate
feed.multiFactory - used to instantiate a new multi-key
feed.NullPointerException - if any of the arguments is null.IllegalArgumentException - if subjects contains an empty string.protected static <R extends EObject,C extends EMessage,F extends net.sf.eBus.client.ESingleFeed,M extends EMultiFeed<C,F>> M openQuery(R client, Class<? extends C> mc, Pattern query, EFeed.FeedScope scope, ECondition condition, EMultiFeed.SubordinateFeedFactory<R,F> subFactory, EMultiFeed.MultiFeedFactory<M,C,F> multiFactory)
R - eBus role used with this multi-key feed.C - feed based on this message class.F - subordinate feed class.M - multi-key feed class.client - application object interacting with the
feed.mc - feed message class.query - message subject regular expression query.scope - whether the feed supports local feeds,
remote feeds, or both.condition - the optional condition used by the
subordinate feed.subFactory - used to instantiate a new subordinate
feed.multiFactory - used to instantiate a new multi-key
feed.NullPointerException - if any of the arguments is null.Copyright © 2019. All rights reserved.