Package net.engio.mbassy.bus
Class AbstractPubSubSupport<T>
- java.lang.Object
-
- net.engio.mbassy.bus.AbstractPubSubSupport<T>
-
- Type Parameters:
T-
- All Implemented Interfaces:
PubSubSupport<T>,RuntimeProvider
- Direct Known Subclasses:
AbstractSyncAsyncMessageBus,SyncMessageBus
public abstract class AbstractPubSubSupport<T> extends java.lang.Object implements PubSubSupport<T>
The base class for all message bus implementations.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringERROR_HANDLER_MSGprivate java.util.List<IPublicationErrorHandler>errorHandlersprivate MessagePublication.FactorypublicationFactoryprivate BusRuntimeruntimeprivate SubscriptionManagersubscriptionManager
-
Constructor Summary
Constructors Constructor Description AbstractPubSubSupport(IBusConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected MessagePublicationcreateMessagePublication(T message)protected MessagePublication.FactorygetPublicationFactory()java.util.Collection<IPublicationErrorHandler>getRegisteredErrorHandlers()BusRuntimegetRuntime()protected java.util.Collection<Subscription>getSubscriptionsByMessageType(java.lang.Class messageType)protected voidhandlePublicationError(PublicationError error)voidsubscribe(java.lang.Object listener)Subscribe all handlers of the given listener.java.lang.StringtoString()booleanunsubscribe(java.lang.Object listener)Immediately remove all registered message handlers (if any) of the given listener.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.engio.mbassy.bus.common.PubSubSupport
publish
-
-
-
-
Field Detail
-
errorHandlers
private final java.util.List<IPublicationErrorHandler> errorHandlers
-
publicationFactory
private final MessagePublication.Factory publicationFactory
-
subscriptionManager
private final SubscriptionManager subscriptionManager
-
runtime
private final BusRuntime runtime
-
ERROR_HANDLER_MSG
public static final java.lang.String ERROR_HANDLER_MSG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractPubSubSupport
public AbstractPubSubSupport(IBusConfiguration configuration)
-
-
Method Detail
-
getPublicationFactory
protected MessagePublication.Factory getPublicationFactory()
-
getRegisteredErrorHandlers
public java.util.Collection<IPublicationErrorHandler> getRegisteredErrorHandlers()
-
unsubscribe
public boolean unsubscribe(java.lang.Object listener)
Description copied from interface:PubSubSupportImmediately remove all registered message handlers (if any) of the given listener. When this call returns all handlers have effectively been removed and will not receive any messages (provided that running publications (iterators) in other threads have not yet obtained a reference to the listener) A call to this method passing any object that is not subscribed will not have any effect and is silently ignored.- Specified by:
unsubscribein interfacePubSubSupport<T>- Returns:
- true, if the listener was found and successfully removed false otherwise
-
subscribe
public void subscribe(java.lang.Object listener)
Description copied from interface:PubSubSupportSubscribe all handlers of the given listener. Any listener is only subscribed once -> subsequent subscriptions of an already subscribed listener will be silently ignored- Specified by:
subscribein interfacePubSubSupport<T>
-
getRuntime
public BusRuntime getRuntime()
- Specified by:
getRuntimein interfaceRuntimeProvider
-
createMessagePublication
protected MessagePublication createMessagePublication(T message)
-
getSubscriptionsByMessageType
protected java.util.Collection<Subscription> getSubscriptionsByMessageType(java.lang.Class messageType)
-
handlePublicationError
protected void handlePublicationError(PublicationError error)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-