Class EFeed
- java.lang.Object
-
- net.sf.eBus.client.EFeed
-
- All Implemented Interfaces:
IEFeed
- Direct Known Subclasses:
EMultiFeed,ENotifyFeed,EPatternFeed,EReplyFeed,EReplyFeed.ERequest,ERequestFeed,ERequestFeed.ERequest,ERequestMonitorFeed
public abstract class EFeed extends java.lang.Object implements IEFeed
Applications interface with eBus through feed instances. An application class implements the eBus interface associated with the feed (for example,EPublisherforEPublishFeed), opens a feed instance, and then activates the feed. The feed can be activated, deactivated multiple times. Once the feed isclosed, the feed instance cannot be used again. A new feed instance must be opened again.An application defines a feed's
scopewhen opening the feed. This scope defines the feed's visibility. That feed may be visible only within the local JVM, within both local and remote JVMs, and in remote JVMs only. For example, if asubscription feedhas local-only scope, then it will receive notifications from localpublisher feedsonly. Notifications from remote publishers will not be forwarded to the local-only subscriber. The following table shows the interface between feed scopes:Feed Scope Local Only Local & Remote Remote Only Local Only Match Match No match Local & Remote Match Match Match Remote Only No match Match No match (Notice that a remote feed may only support a local & remote feed and not other remote only feeds.)
Feed scope gives the application developer control over how "far" a message will go. If a notification message is intended to stay within a JVM, both the publish and subscribe feeds may be set to a local only scope. If a notification is meant for remote access only, the the publish feed is set to remote only scope. These examples also apply to request/reply feeds.
eBus calls an application instance back from only one thread at any given time. While that thread may change over time, only one eBus thread will callback the application instance at any given time. The eBus API is thread-safe and an application may call eBus methods from multiple, simultaneous threads. The benefit of this model is that if an application instance is accessed only by eBus only and not by any other non-eBus thread, then the application instance is effectively single-threaded. Such an application instance does not need to use
synchronizedkeyword or locks, simplifying the application class implementation.A feed maintains a
weak referenceto the application instance. If the application is finalized while still owning open feeds, those feeds will be automatically closed when eBus detects this finalization.Each feed is assigned a identifier that is unique within the application instance scope and feed lifespan. Once a feed is closed, its identifier is recycled. Put in another way: an application instance's active feeds all have unique integer identifiers. These identifiers are not unique across different application instances. These identifiers are not unique across an application instance lifespan if that instance opens and closes feeds multiple times. It is likely that newly opened feed will have the same identifier as a previously closed feed.
The eBus API is intended to be extended with new feed subclasses. These extensions would provide more sophisticated notification and request/reply types. One example is a notification feed that combines historical and live updates or just historical, depending on what the subscriber requests. This allows a subscriber to join the feed at any time, not missing any previously posted notifications.
Message Key Dictionary
eBus v. 4.5.0 added the ability to directly add messages keys to the eBus message key dictionary and retrieve keys from said dictionary. Prior to this version, message keys were indirectly added to the dictionary when opening feeds. This feature added to support the new multikey feeds
EMultiPublishFeed,EMultiSubscribeFeed, andEMultiReplyFeed. Multi-subject feeds may use aqueryto match a variable number of keys. This is whyaddKey(EMessageKey),addAllKeys(java.util.Collection)andloadKeys(ObjectInputStream)methods are provided: unless the message key dictionary is populated with keys prior to creating a multi-subject query feed, the query would find no matching keys.Multi-subject feeds act as proxies between the application client and the individual
EPublishFeed,ESubscribeFeed,ERequestFeedandEReplyFeedin the multi-subject feed. The multi-subject feed opens, advertises/subscribes, and closes all subordinate feeds in unison. The individual feeds all reference the same client and client callback methods. If a multi-subject feed is for 100 subjects, then the client receives callbacks from all 100 subordinate feed and not for the single multi-subject feed.Note: a multi-subject feed is not
EFeedsubclass. However, multi-subject feed behavior is the same as anEFeedand may be treated by the application as if it were anEFeed.- Author:
- Charles W. Rapp
- See Also:
ESubject,ENotifyFeed,EPublishFeed,ESubscribeFeed,ERequestFeed,EReplyFeed,EMultiPublishFeed,EMultiSubscribeFeed,EMultiRequestFeed,EMultiReplyFeed
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classEFeed.AbstractClientTaskBase class for eBus client callback tasks created by feeds.protected static classEFeed.Builder<F extends EFeed,T extends EObject,B extends EFeed.Builder<F,T,?>>Base class for allEFeedbuilders.static classEFeed.FeedScopeFeed scope is either restricted to this JVM, to both this JVM and remote JVMs, and to remote JVMs only.protected classEFeed.NotifyTaskThis task forwards a notification message toESubscriber.notify(ENotificationMessage, IESubscribeFeed).protected classEFeed.StatusTask<T extends IEFeed>Used to issue a feed status callback.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringFEED_IS_INACTIVEMessage associated with attempting to use an inactive message feed.static java.lang.StringFEED_NOT_ADVERTISEDMessage associated with attempting to use an unadvertised message feed.protected EClientmEClientThe client owning this feed.protected intmFeedIdImmutable identifier unique within the client.protected EFeedStatemFeedStateprotected booleanmInPlaceSet totruewhen this feed is connected to its subject.protected java.util.concurrent.atomic.AtomicBooleanmIsActiveReturnstrueif this feed is active, meaning that it can still be used by the client.protected EFeed.FeedScopemScopeThe feed scope is either limited to this local JVM only, remote JVMs only, and both local and remote JVMs.static EConditionNO_CONDITIONThe default condition always returns true.protected static java.lang.StringNOTIFY_METHODstatic java.lang.StringNULL_CLIENTMessage associated with using anull EClient.
-
Constructor Summary
Constructors Modifier Constructor Description protectedEFeed(EClient client, EFeed.FeedScope feedScope)Creates an eBus feed for the given client subject, scope, and feed type.protectedEFeed(EFeed.Builder<?,?,?> builder)Creates an eBus feed based on the given builder configuration.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static voidaddAllKeys(java.util.Collection<EMessageKey> keys)Adds the given message key collection to the message key dictionary if all keys are not null and reference notification and/or request messages.static voidaddKey(EMessageKey key)Addskeyto the eBus message key dictionary ifkeyis not already defined.static voidaddListener(ISubjectListener l)Adds the given subject listener to the listeners list.protected static voidcheckScopes(EMessageKey key, EFeed.FeedScope scope)Checks if the message scope and feed scope are in agreement.intclientId()Returns the feed client identifier.java.lang.StringclientName()Returns feed client name as set by eBus object.voidclose()Closes this feed, marking it as inactive.static voidcreateDispatcher(EConfigure.Dispatcher dispatcher)Creates a new client dispatcher run queue based on the given configuration.static java.lang.StringdefaultDispatcher()Returns the eBus default dispatcher's name.EClienteClient()Returns the eBus client referenced by this feed.booleanequals(java.lang.Object o)Returnstrueifois a non-null EFeedinstance with equal client and feed identifiers.intfeedId()Returns the unique feed identifier.EFeedStatefeedState()Returns the current feed state.static java.util.List<EMessageKey>findKeys()Returns a non-null, possibly empty, message key list taken from the current message key dictionary entries.static java.util.List<EMessageKey>findKeys(java.lang.Class<? extends EMessage> mc)Returns a list containing message keys for the given message class found in the message key dictionary.static java.util.List<EMessageKey>findKeys(java.lang.Class<? extends EMessage> mc, Pattern query)Returns a list containing message keys for the given message class and subject pattern found in the message key dictionary.inthashCode()Returns the hash of the client and feed identifiers.protected abstract voidinactivate()Closes the feed.booleaninPlace()Returnstrueif this feed is "in place" (subscribed or advertised) andfalseotherwise.booleanisActive()Returnstrueif this feed is still active andfalseif inactive.booleanisFeedUp()protected booleanisOverridden(java.lang.String methodName, java.lang.Class<?>... params)Returnstrueif the application object stored inEClientdefines a method with the given name and parameters.static voidloadKeys(java.io.ObjectInputStream ois)Reads themessage keyscontained in the given object input stream and loads them back into the eBus message key dictionary.EClient.ClientLocationlocation()static voidregister(EObject client)Registers the application objectclientwith eBus, assigning the client to the dispatcher configured for the client's class, and using the definedEObject.startup()andEObject.shutdown()methods.static voidregister(EObject client, java.lang.String dispatcherName)Registers the application objectclientwith eBus, assigningclientto the named dispatcher.static voidregister(EObject client, java.lang.String dispatcherName, java.lang.Runnable startCb, java.lang.Runnable shutdownCb)Registers the application objectclientwith eBus, assigningclientto the named dispatcher.static voidremoveListener(ISubjectListener l)Removes subject listener from the listeners list.EFeed.FeedScopescope()Returns the feed scope: local only, local & remote, or remote only.static voidsetExhaust(IMessageExhaust exhaust)Sets the message exhaust to the given instance.static voidshutdown(java.util.List<? extends EObject> clients)Call the registered shutdown method for each of the application objects inclientsif-and-only-if the application object is currently started.static voidshutdown(EObject client)Calls the shutdown methodregisteredwith eBus if-and-only-if the application object is currently started.static voidshutdownAll()Calls the shutdown method for all currently registered application objects which are currently started. This method is generally called by an application just prior to shutting down.static voidstartup(java.util.List<? extends EObject> clients)Call the registered start-up method for each of the application objects inclientsif-and-only-if the application object is not currently started.static voidstartup(EObject client)Calls the start-up methodregisteredwith eBus if-and-only-if the application object is not currently started.static voidstartupAll()Calls the start-up method for all currently registered application objects which are not currently started. This method is generally called from an application'sstatic mainmethod after having created and registered the application's eBus objects.static voidstoreKeys(java.io.ObjectOutputStream oos)Writes the entire message key dictionary to the given object output stream.static voidstoreKeys(java.lang.Class<? extends EMessage> mc, java.io.ObjectOutputStream oos)Write those message keys associated with the given message class to the object output stream.static voidstoreKeys(java.lang.Class<? extends EMessage> mc, Pattern query, java.io.ObjectOutputStream oos)Write those message keys associated with the given message class and a subject matching the regular expression to the object output stream.protected static intsubclassDistance(java.lang.Class<?> subclass, java.lang.Class<?> bc)Returns the distance between the given subclass and base class.java.lang.StringtoString()Returns a containing the feed message key and data member values.
-
-
-
Field Detail
-
NO_CONDITION
public static final ECondition NO_CONDITION
The default condition always returns true. This default is used so that a notification subscription and request advertisement always have a non-nullcondition, removing the need for aifcondition in message routing code, which improves JIT performance.
-
FEED_IS_INACTIVE
public static final java.lang.String FEED_IS_INACTIVE
Message associated with attempting to use an inactive message feed.- See Also:
- Constant Field Values
-
FEED_NOT_ADVERTISED
public static final java.lang.String FEED_NOT_ADVERTISED
Message associated with attempting to use an unadvertised message feed.- See Also:
- Constant Field Values
-
NULL_CLIENT
public static final java.lang.String NULL_CLIENT
Message associated with using anull EClient.- See Also:
- Constant Field Values
-
NOTIFY_METHOD
protected static final java.lang.String NOTIFY_METHOD
- See Also:
- Constant Field Values
-
mEClient
protected final EClient mEClient
The client owning this feed.EClientmaintains a weak reference to the application instance.
-
mScope
protected final EFeed.FeedScope mScope
The feed scope is either limited to this local JVM only, remote JVMs only, and both local and remote JVMs.
-
mIsActive
protected final java.util.concurrent.atomic.AtomicBoolean mIsActive
Returnstrueif this feed is active, meaning that it can still be used by the client. Returnsfalseif this feed is inactive and cannot be used by the client again. Once a feed is made inactive, it cannot become active again.
-
mInPlace
protected boolean mInPlace
Set totruewhen this feed is connected to its subject. Initialized tofalse.
-
mFeedId
protected final int mFeedId
Immutable identifier unique within the client. In other words, two feeds for two differentEClientinstances may have the samemFeedId.
-
mFeedState
protected EFeedState mFeedState
-
-
Constructor Detail
-
EFeed
protected EFeed(EClient client, EFeed.FeedScope feedScope)
Creates an eBus feed for the given client subject, scope, and feed type. All callback tasks are posted toclient'srun queue.- Parameters:
client- post eBus tasks to this client.feedScope- this feed supports either local, local & remote, or just remote feeds.
-
EFeed
protected EFeed(EFeed.Builder<?,?,?> builder)
Creates an eBus feed based on the given builder configuration.- Parameters:
builder- contains feed configuration.
-
-
Method Detail
-
inactivate
protected abstract void inactivate()
Closes the feed. Performs all necessary work to clean up this feed.
-
feedId
public final int feedId()
Returns the unique feed identifier. The uniqueness is limited to within the client and for the feed lifespan only. When a feed is closed, the feed identifier may be reused.
-
scope
public final EFeed.FeedScope scope()
Returns the feed scope: local only, local & remote, or remote only.
-
eClient
public final EClient eClient()
Returns the eBus client referenced by this feed.
-
isActive
public final boolean isActive()
Returnstrueif this feed is still active andfalseif inactive. Clients may only use active feeds. Once a feed is closed, it is marked inactive and may not be used by the client again.Once a feed is closed, the unique feed identifier may be reused by a newly opened feed.
-
inPlace
public final boolean inPlace()
Returnstrueif this feed is "in place" (subscribed or advertised) andfalseotherwise.
-
isFeedUp
public boolean isFeedUp()
-
feedState
public final EFeedState feedState()
Returns the current feed state. A down state means that messages may not be sent on or received from this feed. An up state means that messages may possibly be sent on or received from this feed.
-
close
public void close()
Closes this feed, marking it as inactive. If this feed is activated, then the feed is de-activated first. The feed unique identifier is returned to the available feed identifier pool and may be assigned to a newly opened feed.If this feed is already inactive, then does nothing.
-
equals
public boolean equals(java.lang.Object o)
Returnstrueifois a non-null EFeedinstance with equal client and feed identifiers. Otherwise returnsfalse.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- comparison object.- Returns:
trueifois a non-null EFeedinstance with equal client and feed identifiers.
-
hashCode
public int hashCode()
Returns the hash of the client and feed identifiers.- Overrides:
hashCodein classjava.lang.Object- Returns:
- hash based on the client and feed identifiers.
-
toString
public java.lang.String toString()
Returns a containing the feed message key and data member values.- Overrides:
toStringin classjava.lang.Object- Returns:
- textual representation of this feed.
-
clientId
public final int clientId()
Returns the feed client identifier. This identifier is guaranteed unique for the application instance's lifespan. The identifier is re-used once eBus detects that the application instance is finalized. This integer identifier may be used by two different application instances over the application run time but only if the two instances do not exist at the same time.- Returns:
- unique client identifier.
-
clientName
public final java.lang.String clientName()
Returns feed client name as set by eBus object.- Returns:
- feed client name.
-
location
public final EClient.ClientLocation location()
- Returns:
- client location.
-
defaultDispatcher
public static java.lang.String defaultDispatcher()
Returns the eBus default dispatcher's name. Used whenregisteringa client to the default dispatcher.- Returns:
- default dispatcher name.
-
findKeys
public static java.util.List<EMessageKey> findKeys()
Returns a non-null, possibly empty, message key list taken from the current message key dictionary entries.- Returns:
- list message key dictionary entries.
-
findKeys
public static java.util.List<EMessageKey> findKeys(java.lang.Class<? extends EMessage> mc)
Returns a list containing message keys for the given message class found in the message key dictionary. The message class should reference either a notification or request message class since only those classes are stored in the message key dictionary. If this is not the case, then an empty list is returned.- Parameters:
mc- message class.- Returns:
- a non-
nulland possibly empty message key list.
-
findKeys
public static java.util.List<EMessageKey> findKeys(java.lang.Class<? extends EMessage> mc, Pattern query)
Returns a list containing message keys for the given message class and subject pattern found in the message key dictionary. The message class should reference either a notification or request message class since only those classes are stored in the message key dictionary. If this is not the case, then an empty list is returned.- Parameters:
mc- message class.query- message subject regular expression query.- Returns:
- a non-
nulland possibly empty message key list.
-
addListener
public static void addListener(ISubjectListener l)
Adds the given subject listener to the listeners list. Does nothing if the listener is already registered.- Parameters:
l- add this subject listener.
-
removeListener
public static void removeListener(ISubjectListener l)
Removes subject listener from the listeners list.- Parameters:
l- remove this subject listener.
-
addKey
public static void addKey(EMessageKey key)
Addskeyto the eBus message key dictionary ifkeyis not already defined.keymust reference either a notification or request message since only those message keys are stored in the message key dictionary.- Parameters:
key- add this message key to the subject- Throws:
java.lang.IllegalArgumentException- ifkeyisnullor does not reference either aENotificationMessageorERequestMessage.
-
addAllKeys
public static void addAllKeys(java.util.Collection<EMessageKey> keys)
Adds the given message key collection to the message key dictionary if all keys are not null and reference notification and/or request messages. Put conversely, ifkeyscontains anullor non-notification/ request key, then none of the keys is placed into the message key dictionary.The listed keys must reference either a notification or request message since only those message keys are stored in the message key dictionary. The list may consist of a mixture of notification and request message keys.
- Parameters:
keys- put these notification and/or request message keys into the message key dictionary.- Throws:
java.lang.IllegalArgumentException- ifkeyscontains anullor does not reference either aENotificationMessageorERequestMessage.
-
setExhaust
public static void setExhaust(IMessageExhaust exhaust)
Sets the message exhaust to the given instance. All notification, request, and reply messages passing through the local eBus are passed toexhaustvia a dispatch thread. Caller is responsible for opening and closing the exhaust's underlying persistent store appropriately.Note: only one exhaust may be configured at a time. When this method is called, the current exhaust is replace with
exhaust. If an application requires messages to be persisted to multiple destinations, then that must be done via the single application exhaust.If
exhaustisnullthen the default exhaust is used. This default does nothing with the given message.- Parameters:
exhaust- message exhaust message. Passing innullresults in the default exhaust being used.
-
createDispatcher
public static void createDispatcher(EConfigure.Dispatcher dispatcher)
Creates a new client dispatcher run queue based on the given configuration. This method allows new dispatcher run queues to be created dynamically post-JVM start. Normally dispatcher configurations are contained in an eBus configuration file and loaded at JVM start using the Java command line option-Dnet.sf.eBus.config.jsonFile=<config file path>. This technique guarantees that eBus Dispatchers are in place prior to assigned eBus clients to a Dispatcher. But if this is not possible, thencreateDispatchermay be used to create a Dispatcher dynamically. But care must be taken to make sure this is done prior toregisteringan eBus client to that Dispatcher.See
EConfigure.DispatcherandEConfigure.DispatcherBuilderfor detailed information on how dispatchers work and how to build a dispatcher configuration.- Parameters:
dispatcher- dispatcher configuration.- Throws:
java.lang.NullPointerException- ifdispatcherisnull.java.lang.IllegalStateException- if a dispatcher namedEConfigure.ThreadConfig.name()already exists.- See Also:
EConfigure.Dispatcher,EConfigure.DispatcherBuilder,EConfigure.dispatcherBuilder()
-
register
public static void register(EObject client)
Registers the application objectclientwith eBus, assigning the client to the dispatcher configured for the client's class, and using the definedEObject.startup()andEObject.shutdown()methods. Once registered,clientmay be started using thestartup(EObject)orstartup(List)methods.Note: this method must be called before
clientopens any feeds. Failure to do so results in a thrownIllegalStateException.- Parameters:
client- register this application object with eBus.- Throws:
java.lang.NullPointerException- ifclientisnull.java.lang.IllegalStateException- ifclientis already registered with eBus. This will happen ifclienthas opened any feeds prior to making this call.- See Also:
register(EObject, String),register(EObject, String, Runnable, Runnable),startup(EObject),shutdown(EObject)
-
register
public static void register(EObject client, java.lang.String dispatcherName)
Registers the application objectclientwith eBus, assigningclientto the named dispatcher. This method allows individual application objects to be assigned to a dispatcher rather than by class. The purpose here is to allow objects within a class to be assigned to different dispatchers based on application need. That is, certain objects may be assigned to a higher priority dispatcher and the rest assigned to a lower priority dispatcher.Once registered,
clientmay be started by callingstartup(EObject)orstartup(List)methods which, in turn, calls the definedEObject.startup()method.Note: this method must be called before
clientopens any feeds. Failure to do so results in a thrownIllegalStateException.- Parameters:
client- register this application client with eBus.dispatcherName- the dispatcher name.- Throws:
java.lang.NullPointerException- ifclientisnullordispatcherNameisnulljava.lang.IllegalArgumentException- ifdispatcherNameis empty or does not reference a configured dispatcher.java.lang.IllegalStateException- ifclientis already registered with eBus. This will happen ifclienthas opened any feeds prior to making this call.
-
register
public static void register(EObject client, java.lang.String dispatcherName, java.lang.Runnable startCb, java.lang.Runnable shutdownCb)
Registers the application objectclientwith eBus, assigningclientto the named dispatcher. This method allows individual application objects to be assigned to a dispatcher rather than by class. The purpose here is to allow objects within a class to be assigned to different dispatchers based on application need. That is, certain objects may be assigned to a higher priority dispatcher and the rest assigned to a lower priority dispatcher.Once registered,
clientmay be started by callingstartup(EObject)orstartup(List)methods which, in turn, callsstartCb.Note: this method must be called before
clientopens any feeds. Failure to do so results in a thrownIllegalStateException.- Parameters:
client- register this application client with eBus.dispatcherName- the dispatcher name.startCb-clientstart-up method callback.shutdownCb-clientshutdown method callback.- Throws:
java.lang.NullPointerException- if any of the arguments isnull.java.lang.IllegalArgumentException- ifdispatcherNameis either an empty string or does not reference a known dispatcher.java.lang.IllegalStateException- ifclientis already registered with eBus. This will happen ifclienthas opened any feeds prior to making this call.
-
startup
public static void startup(EObject client)
Calls the start-up methodregisteredwith eBus if-and-only-if the application object is not currently started. If application object is started, then the start-up method will not be called again.Note: it is possible to start an application object multiple times if that object is shut down between each start.
The start-up method is called from within the context of the object's run queue. Because the application object is started on an eBus thread, the start-up method will not be run concurrently with any other eBus callback.
- Parameters:
client- start this eBus client.- Throws:
java.lang.NullPointerException- ifclientisnull.java.lang.IllegalStateException- ifclientis not registered with eBus.- See Also:
register(EObject),register(EObject, String),register(EObject, String, Runnable, Runnable),startup(List),startupAll(),shutdown(EObject),shutdown(List),shutdownAll()
-
startup
public static void startup(java.util.List<? extends EObject> clients)
Call the registered start-up method for each of the application objects inclientsif-and-only-if the application object is not currently started. If any of the applications is currently started, then that objects start-up method will not be called again.Note: it is possible to start an application object multiple times if that object is shut down between each start.
The start-up method is called from within the context of the object's run queue. Because the application object is started on an eBus thread, the start-up method will not be run concurrently with any other eBus callback.
- Parameters:
clients- start these eBus clients.- Throws:
java.lang.NullPointerException- ifclientsisnullor contains anullentry.java.lang.IllegalStateException- ifclientscontains an entry that is not registered with eBus.- See Also:
register(EObject),register(EObject, String),register(EObject, String, Runnable, Runnable),startup(EObject),startupAll(),shutdown(EObject),shutdown(List),shutdownAll()
-
startupAll
public static void startupAll()
Calls the start-up method for all currently registered application objects which are not currently started. This method is generally called from an application'sstatic mainmethod after having created and registered the application's eBus objects.Note: it is possible to start an application object multiple times if that object is shut down between each start.
The start-up method is called from within the context of the object's run queue. Because the application object is started on an eBus thread, the start-up method will not be run concurrently with any other eBus callback.
-
shutdown
public static void shutdown(EObject client)
Calls the shutdown methodregisteredwith eBus if-and-only-if the application object is currently started. If application object is not started, then the shutdown method will not be called again.Note: it is possible to shut down an application object multiple times if that object is started up between each shutdown.
The shutdown method is called from within the context of the object's run queue. Because the application object is stopped on an eBus thread, the shutdown method will not be run concurrently with any other eBus callback.
- Parameters:
client- stop this eBus client.- Throws:
java.lang.NullPointerException- ifclientisnull.java.lang.IllegalStateException- ifclientis not registered with eBus.- See Also:
register(EObject),register(EObject, String),register(EObject, String, Runnable, Runnable),startup(EObject),startup(List),startupAll(),shutdown(List),shutdownAll()
-
shutdown
public static void shutdown(java.util.List<? extends EObject> clients)
Call the registered shutdown method for each of the application objects inclientsif-and-only-if the application object is currently started. If any of the applications is not currently started, then that objects shutdown method will not be called again.Note: it is possible to shut down an application object multiple times if that object is started up between each shutdown.
The shutdown method is called from within the context of the object's run queue. Because the application object is stopped on an eBus thread, the shutdown method will not be run concurrently with any other eBus callback.
- Parameters:
clients- stop these eBus clients.- Throws:
java.lang.NullPointerException- ifclientsisnullor contains anullentry.java.lang.IllegalStateException- ifclientscontains an entry that is not registered with eBus.- See Also:
register(EObject),register(EObject, String),register(EObject, String, Runnable, Runnable),startup(EObject),startup(List),startupAll(),shutdown(EObject),shutdownAll()
-
shutdownAll
public static void shutdownAll()
Calls the shutdown method for all currently registered application objects which are currently started. This method is generally called by an application just prior to shutting down.Note: it is possible to stop an application object multiple times if that object is started between each shut down.
The shutdown method is called from within the context of the object's run queue. Because the application object is stopped on an eBus thread, the start-up method will not be run concurrently with any other eBus callback.
-
storeKeys
public static void storeKeys(java.io.ObjectOutputStream oos) throws java.io.IOExceptionWrites the entire message key dictionary to the given object output stream. Only message keys are written to the object output stream. The associated eBus subjects and their related feeds are not stored. When the message key is re-loaded from the object stream at application start, the eBus subjects are recreated but not the feeds. Feeds must be re-opened by the application upon start.Caller is responsible for opening
oosprior to calling this method and closingoosafter this method returns.- Parameters:
oos- load message keys to this object output stream.- Throws:
java.io.IOException- if an error occurs writing message keys tooos.- See Also:
storeKeys(Class, ObjectOutputStream),storeKeys(Class, Pattern, ObjectOutputStream),loadKeys(ObjectInputStream)
-
storeKeys
public static void storeKeys(java.lang.Class<? extends EMessage> mc, java.io.ObjectOutputStream oos) throws java.io.IOException
Write those message keys associated with the given message class to the object output stream. Only message keys are written to the object output stream. The associated eBus subjects and their related feeds are not stored. When the message key is re-loaded from the object stream at application start, the eBus subjects are recreated but not the feeds. Feeds must be re-opened by the application upon start.Caller is responsible for opening
oosprior to calling this method and closingoosafter this method returns.- Parameters:
mc- store message keys with this message class.oos- load message keys to this object output stream.- Throws:
java.io.IOException- if an error occurs writing message keys tooos.- See Also:
storeKeys(ObjectOutputStream),storeKeys(Class, Pattern, ObjectOutputStream),loadKeys(ObjectInputStream)
-
storeKeys
public static void storeKeys(java.lang.Class<? extends EMessage> mc, Pattern query, java.io.ObjectOutputStream oos) throws java.io.IOException
Write those message keys associated with the given message class and a subject matching the regular expression to the object output stream. Only message keys are written to the object output stream. The associated eBus subjects and their related feeds are not stored. When the message key is re-loaded from the object stream at application start, the eBus subjects are recreated but not the feeds. Feeds must be re-opened by the application upon start.Caller is responsible for opening
oosprior to calling this method and closingoosafter this method returns.- Parameters:
mc- store message keys with this message class.query- store message keys with a subject matching this regular expression.oos- load message keys to this object output stream.- Throws:
java.io.IOException- if an I/O error occurs when storing the message keys.- See Also:
storeKeys(ObjectOutputStream),storeKeys(Class, ObjectOutputStream),loadKeys(ObjectInputStream)
-
loadKeys
public static void loadKeys(java.io.ObjectInputStream ois) throws java.io.IOExceptionReads themessage keyscontained in the given object input stream and loads them back into the eBus message key dictionary. eBus subjects are re-created but not their associated feeds. The application is responsible for re-opening feeds when the application starts.Message keys defined prior to calling this method are not overwritten or replaced by duplicates loaded from the object input stream.
Caller is responsible for opening
oisprior to calling this method and closingoisafter this method returns.- Parameters:
ois- read in message keys from this object input stream.- Throws:
java.io.IOException- if an I/O error occurs reading in the
-
isOverridden
protected final boolean isOverridden(java.lang.String methodName, java.lang.Class<?>... params)Returnstrueif the application object stored inEClientdefines a method with the given name and parameters. Returnsfalseif the application object does not define the method or inherits a default implementation of the method.- Parameters:
methodName- method name.params- method parameters.- Returns:
trueifclazzoverrides the method.
-
checkScopes
protected static void checkScopes(EMessageKey key, EFeed.FeedScope scope)
Checks if the message scope and feed scope are in agreement. That is, if the message scope is local-only but the feed scope is not, then throws anIllegalArgumentException.- Parameters:
key- message key.scope- feed scope.- Throws:
java.lang.IllegalArgumentException- ifkeyscope is local-only andscopeis notFeedScope.LOCAL_ONLY.
-
subclassDistance
protected static int subclassDistance(java.lang.Class<?> subclass, java.lang.Class<?> bc)Returns the distance between the given subclass and base class. If a direct subclass of base class, then the returned value is one. If not a subclass of base class, then the returned value is < zero.- Parameters:
subclass- check if this class is descended from the base class.bc- base class.- Returns:
- distance from subclass to base class or < zero
if
subclassis not descended frombc.
-
-