public class DefaultEventBus extends ThreadSafeEventService
org.scijava.event.bushe.EventService implementation for SciJava.
It is called "DefaultEventBus" rather than "DefaultEventService" to avoid a
name clash with DefaultEventService, which is not an
org.scijava.event.bushe.EventService but rather a SciJava
Service implementation.
CLEANUP_PERIOD_MS_DEFAULT, CLEANUP_START_THRESHOLD_DEFAULT, CLEANUP_STOP_THRESHOLD_DEFAULT, LOG| Constructor and Description |
|---|
DefaultEventBus(ThreadService threadService,
LogService log) |
| Modifier and Type | Method and Description |
|---|---|
void |
publish(Object event)
Publishes an object so that subscribers will be notified if they subscribed to the object's class, one of its
subclasses, or to one of the interfaces it implements.
|
protected void |
publish(Object event,
String topic,
Object eventObj,
List subscribers,
List vetoSubscribers,
StackTraceElement[] callingStack)
All publish methods call this method.
|
void |
publish(String topicName,
Object eventObj)
Publishes an object on a topic name so that all subscribers to that name or a Regular Expression that matches
the topic name will be notified.
|
void |
publish(Type genericType,
Object event)
Use this method to publish generified objects to subscribers of Types, i.e. subscribers that use
subscribe(Type, EventSubscriber), and to publish to subscribers of the non-generic type. |
void |
publishLater(Object event) |
void |
publishLater(String topicName,
Object eventObj) |
void |
publishLater(Type genericType,
Object event) |
void |
publishNow(Object event) |
void |
publishNow(String topicName,
Object eventObj) |
void |
publishNow(Type genericType,
Object event) |
addEventToCache, clearAllSubscribers, clearCache, clearCache, clearCache, clearCache, decWeakRefPlusProxySubscriberCount, getCachedEvents, getCachedTopicData, getCacheSizeForEventClass, getCacheSizeForTopic, getCleanupPeriodMS, getCleanupStartThreshhold, getCleanupStopThreshold, getDefaultCacheSizePerClassOrTopic, getLastEvent, getLastTopicData, getRealSubscriberAndCleanStaleSubscriberIfNecessary, getSubscribers, getSubscribers, getSubscribers, getSubscribers, getSubscribersByPattern, getSubscribersToClass, getSubscribersToExactClass, getSubscribersToPattern, getSubscribersToTopic, getVetoEventListeners, getVetoSubscribers, getVetoSubscribers, getVetoSubscribers, getVetoSubscribersByPattern, getVetoSubscribersToClass, getVetoSubscribersToExactClass, getVetoSubscribersToTopic, handleException, handleException, handleVeto, incWeakRefPlusProxySubscriberCount, onEventException, removeProxySubscriber, setCacheSizeForEventClass, setCacheSizeForTopic, setCacheSizeForTopic, setCleanupPeriodMS, setCleanupStartThreshhold, setCleanupStopThreshold, setDefaultCacheSizePerClassOrTopic, setStatus, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeExactly, subscribeExactlyStrongly, subscribeStrongly, subscribeStrongly, subscribeStrongly, subscribeVetoException, subscribeVetoListener, subscribeVetoListener, subscribeVetoListener, subscribeVetoListener, subscribeVetoListenerExactly, subscribeVetoListenerExactlyStrongly, subscribeVetoListenerStrongly, subscribeVetoListenerStrongly, subscribeVetoListenerStrongly, unsubscribe, unsubscribe, unsubscribe, unsubscribe, unsubscribe, unsubscribe, unsubscribe, unsubscribeExactly, unsubscribeExactly, unsubscribeVeto, unsubscribeVeto, unsubscribeVeto, unsubscribeVetoExactly, unsubscribeVetoListener, unsubscribeVetoListener, unsubscribeVetoListener, unsubscribeVetoListener, unsubscribeVetoListenerExactlypublic DefaultEventBus(ThreadService threadService, LogService log)
public void publishNow(Object event)
public void publishLater(Object event)
public void publish(Object event)
publish in class ThreadSafeEventServiceevent - the object to publishEventService.publish(Object)public void publish(Type genericType, Object event)
subscribe(Type, EventSubscriber), and to publish to subscribers of the non-generic type.
Due to generic type erasure, the type must be supplied by the caller. You can get a declared object's
type by using the TypeReference class. For Example:
TypeReference<List<Trade>> subscribingTypeReference = new TypeReference<List<Trade>>(){};
EventBus.subscribe(subscribingTypeReference.getType(), mySubscriber);
EventBus.subscribe(List.class, thisSubscriberWillGetCalledToo);
...
//Likely in some other class
TypeReference<List<Trade>> publishingTypeReference = new TypeReference<List<Trade>>(){};
List<Trade> trades = new ArrayList<Trade>();
EventBus.publish(publishingTypeReference.getType(), trades);
trades.add(trade);
EventBus.publish(publishingTypeReference.getType(), trades);
publish in class ThreadSafeEventServicegenericType - the generified type of the published object.event - The event that occurredEventService.publish(java.lang.reflect.Type, Object)public void publish(String topicName, Object eventObj)
publish in class ThreadSafeEventServicetopicName - The name of the topic subscribed toeventObj - the object to publishEventService.publish(String,Object)protected void publish(Object event, String topic, Object eventObj, List subscribers, List vetoSubscribers, StackTraceElement[] callingStack)
ThreadSafeEventServicepublish in class ThreadSafeEventServiceevent - the event to publish, null if publishing on a topictopic - if publishing on a topic, the topic to publish on, else nulleventObj - if publishing on a topic, the eventObj to publish, else nullsubscribers - the subscribers to publish to - must be a snapshot copyvetoSubscribers - the veto subscribers to publish to - must be a snapshot copy.callingStack - the stack that called this publication, helpful for reporting errors on other threadsCopyright © 2009–2025 SciJava. All rights reserved.