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.String
ERROR_HANDLER_MSG
private java.util.List<IPublicationErrorHandler>
errorHandlers
private MessagePublication.Factory
publicationFactory
private BusRuntime
runtime
private SubscriptionManager
subscriptionManager
-
Constructor Summary
Constructors Constructor Description AbstractPubSubSupport(IBusConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected MessagePublication
createMessagePublication(T message)
protected MessagePublication.Factory
getPublicationFactory()
java.util.Collection<IPublicationErrorHandler>
getRegisteredErrorHandlers()
BusRuntime
getRuntime()
protected java.util.Collection<Subscription>
getSubscriptionsByMessageType(java.lang.Class messageType)
protected void
handlePublicationError(PublicationError error)
void
subscribe(java.lang.Object listener)
Subscribe all handlers of the given listener.java.lang.String
toString()
boolean
unsubscribe(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:PubSubSupport
Immediately 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:
unsubscribe
in 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:PubSubSupport
Subscribe 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:
subscribe
in interfacePubSubSupport<T>
-
getRuntime
public BusRuntime getRuntime()
- Specified by:
getRuntime
in 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:
toString
in classjava.lang.Object
-
-