public class SwingEventService extends ThreadSafeEventService
EventService
implementation for Swing.
This class is Swing thread-safe. All publish() calls NOT on the Swing EventDispatchThread thread are queued onto the
EDT. If the calling thread is the EDT, then this is a simple pass-through (i.e the subscribers are notified on the
same stack frame, just like they would be had they added themselves via Swing addXXListener methods).CLEANUP_PERIOD_MS_DEFAULT, CLEANUP_START_THRESHOLD_DEFAULT, CLEANUP_STOP_THRESHOLD_DEFAULT, LOG
Constructor and Description |
---|
SwingEventService()
By default, the SwingEventService is constructed such that any listener that takes over 200 ms causes an
SubscriberTimingEvent to be published.
|
SwingEventService(Long timeThresholdForEventTimingEventPublication) |
SwingEventService(Long timeThresholdForEventTimingEventPublication,
boolean subscribeTimingEventsInternally)
Create a SwingEventService is such that any listener that takes over timeThresholdForEventTimingEventPublication
milliseconds causes an EventSubscriberTimingEvent to be published.
|
Modifier and Type | Method and Description |
---|---|
protected void |
publish(Object event,
String topic,
Object eventObj,
List subscribers,
List vetoSubscribers,
StackTraceElement[] callingStack)
Same as ThreadSafeEventService.publish(), except if the call is coming from a thread that is not the Swing Event
Dispatch Thread, the request is put on the EDT through a a call to SwingUtilities.invokeLater().
|
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, publish, publish, publish, removeProxySubscriber, setCacheSizeForEventClass, setCacheSizeForTopic, setCacheSizeForTopic, setCleanupPeriodMS, setCleanupStartThreshhold, setCleanupStopThreshold, setDefaultCacheSizePerClassOrTopic, setStatus, subscribe, subscribe, subscribe, subscribe, subscribe, subscribeExactly, subscribeExactlyStrongly, subscribeStrongly, subscribeStrongly, subscribeStrongly, subscribeTiming, 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, unsubscribeVetoListenerExactly
public SwingEventService()
public SwingEventService(Long timeThresholdForEventTimingEventPublication)
public SwingEventService(Long timeThresholdForEventTimingEventPublication, boolean subscribeTimingEventsInternally)
ThreadSafeEventService.subscribeTiming(SubscriberTimingEvent)
call.
Note that if you use event to launch a modal dialog, the timings will be as long as the dialog is up - this is the
way Swing works.timeThresholdForEventTimingEventPublication
- the longest time a subscriber should spend handling an event,
The service will publish an SubscriberTimingEvent after listener processing if the time was exceeded. If null, no
SubscriberTimingEvent will be issued.subscribeTimingEventsInternally
- add a subscriber to the EventSubscriberTimingEvent internally and call the
protected ThreadSafeEventService.subscribeTiming(SubscriberTimingEvent)
method when they occur. This logs a warning to the
Logger
logger by default.IllegalArgumentException
- if timeThresholdForEventTimingEventPublication is null and
subscribeTimingEventsInternally is true.protected void publish(Object event, String topic, Object eventObj, List subscribers, List vetoSubscribers, StackTraceElement[] callingStack)
publish
in class ThreadSafeEventService
event
- 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 © 2013 Bushe Enterprises, Inc.. All Rights Reserved.