org.bushe.swing.event
Class EventBus

java.lang.Object
  extended by org.bushe.swing.event.EventBus

public class EventBus
extends java.lang.Object

The EventBus provides Swing event publication and subscription services. It is a simple static wrapper around a global instance of an EventService, specifically a SwingEventService.

For Swing Applications the EventBus is nearly all you need, besides some of your own Event classes (if so desired).

The EventBus is really just a convenience class that provides a static wrapper around a global instance of the SwingEventService. For details on the API and implementation, see EventService, SwingEventService, and its parent ThreadSafeEventService. This class exists solely for simplicity. Calling EventBus.subscribeXXX/publishXXX is equivalent to EventServiceLocator.getSwingEventService().subscribeXXX/publishXXX, it is just shorter to type. See EventServiceLocator for details on how a custom EventService can be installed instead of the default SwingEventService.

Author:
Michael Bushe michael@bushe.com
See Also:
EventService, SwingEventService, See package JavaDoc for more information

Constructor Summary
EventBus()
           
 
Method Summary
static void clearAllSubscribers()
           
static void clearCache()
           
static void clearCache(java.lang.Class eventClass)
           
static void clearCache(java.util.regex.Pattern pattern)
           
static void clearCache(java.lang.String topic)
           
static java.util.List getCachedEvents(java.lang.Class eventClass)
           
static java.util.List getCachedTopicData(java.lang.String topic)
           
static int getCacheSizeForEventClass(java.lang.Class eventClass)
           
static int getCacheSizeForTopic(java.lang.String topic)
           
static int getDefaultCacheSizePerClassOrTopic()
           
static EventService getGlobalEventService()
          The EventBus uses a global static EventService.
static java.lang.Object getLastEvent(java.lang.Class eventClass)
           
static java.lang.Object getLastTopicData(java.lang.String topic)
           
static java.util.List getSubscribers(java.lang.Class eventClass)
           
static java.util.List getSubscribers(java.lang.String topic)
           
static java.util.List getSubscribersByPattern(java.lang.String topic)
           
static java.util.List getSubscribersToClass(java.lang.Class eventClass)
           
static java.util.List getSubscribersToExactClass(java.lang.Class eventClass)
           
static java.util.List getSubscribersToTopic(java.lang.String topic)
           
static java.util.List getVetoSubscribers(java.lang.Class eventClass)
           
static java.util.List getVetoSubscribers(java.util.regex.Pattern pattern)
           
static java.util.List getVetoSubscribers(java.lang.String topic)
           
static java.util.List getVetoSubscribersToClass(java.lang.Class eventClass)
           
static java.util.List getVetoSubscribersToExactClass(java.lang.Class eventClass)
           
static void publish(java.lang.Object event)
           
static void publish(java.lang.String topic, java.lang.Object o)
           
static void publish(java.lang.reflect.Type genericType, java.lang.Object o)
           
static void setCacheSizeForEventClass(java.lang.Class eventClass, int cacheSize)
           
static void setCacheSizeForTopic(java.util.regex.Pattern pattern, int cacheSize)
           
static void setCacheSizeForTopic(java.lang.String topicName, int cacheSize)
           
static void setDefaultCacheSizePerClassOrTopic(int defaultCacheSizePerClassOrTopic)
           
static boolean subscribe(java.lang.Class eventClass, EventSubscriber subscriber)
           
static boolean subscribe(java.util.regex.Pattern topicPattern, EventTopicSubscriber subscriber)
           
static boolean subscribe(java.lang.String topic, EventTopicSubscriber subscriber)
           
static boolean subscribe(java.lang.reflect.Type genericType, EventSubscriber subscriber)
           
static boolean subscribeExactly(java.lang.Class eventClass, EventSubscriber subscriber)
           
static boolean subscribeExactlyStrongly(java.lang.Class eventClass, EventSubscriber subscriber)
           
static boolean subscribeStrongly(java.lang.Class eventClass, EventSubscriber subscriber)
           
static boolean subscribeStrongly(java.util.regex.Pattern topicPattern, EventTopicSubscriber subscriber)
           
static boolean subscribeStrongly(java.lang.String topic, EventTopicSubscriber subscriber)
           
static boolean subscribeVetoListener(java.lang.Class eventClass, VetoEventListener vetoListener)
           
static boolean subscribeVetoListener(java.util.regex.Pattern topicPattern, VetoTopicEventListener vetoListener)
           
static boolean subscribeVetoListener(java.lang.String topic, VetoTopicEventListener vetoListener)
           
static boolean subscribeVetoListenerExactly(java.lang.Class eventClass, VetoEventListener vetoListener)
           
static boolean subscribeVetoListenerExactlyStrongly(java.lang.Class eventClass, VetoEventListener vetoListener)
           
static boolean subscribeVetoListenerStrongly(java.lang.Class eventClass, VetoEventListener vetoListener)
           
static boolean subscribeVetoListenerStrongly(java.util.regex.Pattern topicPattern, VetoTopicEventListener vetoListener)
           
static boolean subscribeVetoListenerStrongly(java.lang.String topic, VetoTopicEventListener vetoListener)
           
static boolean unsubscribe(java.lang.Class eventClass, EventSubscriber subscriber)
           
static boolean unsubscribe(java.lang.Class eventClass, java.lang.Object object)
          For usage with annotatations.
static boolean unsubscribe(java.util.regex.Pattern topicPattern, EventTopicSubscriber subscriber)
           
static boolean unsubscribe(java.util.regex.Pattern topicPattern, java.lang.Object subscriber)
          For usage with annotatations.
static boolean unsubscribe(java.lang.String topic, EventTopicSubscriber subscriber)
           
static boolean unsubscribe(java.lang.String topic, java.lang.Object subscriber)
          For usage with annotatations.
static boolean unsubscribeExactly(java.lang.Class eventClass, EventSubscriber subscriber)
           
static boolean unsubscribeExactly(java.lang.Class eventClass, java.lang.Object subscriber)
          For usage with annotatations.
static boolean unsubscribeVetoListener(java.lang.Class eventClass, VetoEventListener vetoListener)
           
static boolean unsubscribeVetoListener(java.util.regex.Pattern topicPattern, VetoTopicEventListener vetoListener)
           
static boolean unsubscribeVetoListener(java.lang.String topic, VetoTopicEventListener vetoListener)
           
static boolean unsubscribeVetoListenerExactly(java.lang.Class eventClass, VetoEventListener vetoListener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventBus

public EventBus()
Method Detail

getGlobalEventService

public static EventService getGlobalEventService()
The EventBus uses a global static EventService. This method is not necessary in usual usage, use the other static methods instead. It is used to expose any other functionality and for framework classes (EventBusAction)

Returns:
the global static EventService

publish

public static void publish(java.lang.Object event)
See Also:
EventService.publish(Object)

publish

public static void publish(java.lang.String topic,
                           java.lang.Object o)
See Also:
EventService.publish(String,Object)

publish

public static void publish(java.lang.reflect.Type genericType,
                           java.lang.Object o)
See Also:
EventService.publish(java.lang.reflect.Type, Object)

subscribe

public static boolean subscribe(java.lang.Class eventClass,
                                EventSubscriber subscriber)
See Also:
EventService.subscribe(Class,EventSubscriber)

subscribe

public static boolean subscribe(java.lang.reflect.Type genericType,
                                EventSubscriber subscriber)
See Also:
EventService.subscribe(java.lang.reflect.Type, EventSubscriber)

subscribeExactly

public static boolean subscribeExactly(java.lang.Class eventClass,
                                       EventSubscriber subscriber)
See Also:
EventService.subscribeExactly(Class,EventSubscriber)

subscribe

public static boolean subscribe(java.lang.String topic,
                                EventTopicSubscriber subscriber)
See Also:
EventService.subscribe(String,EventTopicSubscriber)

subscribe

public static boolean subscribe(java.util.regex.Pattern topicPattern,
                                EventTopicSubscriber subscriber)
See Also:
EventService.subscribe(Pattern,EventTopicSubscriber)

subscribeStrongly

public static boolean subscribeStrongly(java.lang.Class eventClass,
                                        EventSubscriber subscriber)
See Also:
EventService.subscribeStrongly(Class,EventSubscriber)

subscribeExactlyStrongly

public static boolean subscribeExactlyStrongly(java.lang.Class eventClass,
                                               EventSubscriber subscriber)
See Also:
EventService.subscribeExactlyStrongly(Class,EventSubscriber)

subscribeStrongly

public static boolean subscribeStrongly(java.lang.String topic,
                                        EventTopicSubscriber subscriber)
See Also:
EventService.subscribeStrongly(String,EventTopicSubscriber)

subscribeStrongly

public static boolean subscribeStrongly(java.util.regex.Pattern topicPattern,
                                        EventTopicSubscriber subscriber)
See Also:
EventService.subscribeStrongly(Pattern,EventTopicSubscriber)

unsubscribe

public static boolean unsubscribe(java.lang.Class eventClass,
                                  EventSubscriber subscriber)
See Also:
EventService.unsubscribe(Class,EventSubscriber)

unsubscribeExactly

public static boolean unsubscribeExactly(java.lang.Class eventClass,
                                         EventSubscriber subscriber)
See Also:
EventService.unsubscribeExactly(Class,EventSubscriber)

unsubscribe

public static boolean unsubscribe(java.lang.String topic,
                                  EventTopicSubscriber subscriber)
See Also:
EventService.unsubscribe(String,EventTopicSubscriber)

unsubscribe

public static boolean unsubscribe(java.util.regex.Pattern topicPattern,
                                  EventTopicSubscriber subscriber)
See Also:
EventService.unsubscribe(Pattern,EventTopicSubscriber)

unsubscribe

public static boolean unsubscribe(java.lang.Class eventClass,
                                  java.lang.Object object)
For usage with annotatations.

See Also:
EventService.unsubscribe(Class,Object)

unsubscribeExactly

public static boolean unsubscribeExactly(java.lang.Class eventClass,
                                         java.lang.Object subscriber)
For usage with annotatations.

See Also:
EventService.unsubscribeExactly(Class,Object)

unsubscribe

public static boolean unsubscribe(java.lang.String topic,
                                  java.lang.Object subscriber)
For usage with annotatations.

See Also:
EventService.unsubscribe(String,Object)

unsubscribe

public static boolean unsubscribe(java.util.regex.Pattern topicPattern,
                                  java.lang.Object subscriber)
For usage with annotatations.

See Also:
EventService.unsubscribe(Pattern,Object)

subscribeVetoListener

public static boolean subscribeVetoListener(java.lang.Class eventClass,
                                            VetoEventListener vetoListener)
See Also:
EventService.subscribeVetoListener(Class,VetoEventListener)

subscribeVetoListenerExactly

public static boolean subscribeVetoListenerExactly(java.lang.Class eventClass,
                                                   VetoEventListener vetoListener)
See Also:
EventService.subscribeVetoListener(Class,VetoEventListener)

subscribeVetoListener

public static boolean subscribeVetoListener(java.lang.String topic,
                                            VetoTopicEventListener vetoListener)
See Also:
EventService.subscribeVetoListener(String,VetoTopicEventListener)

subscribeVetoListener

public static boolean subscribeVetoListener(java.util.regex.Pattern topicPattern,
                                            VetoTopicEventListener vetoListener)
See Also:
EventService.subscribeVetoListener(Pattern,VetoTopicEventListener)

subscribeVetoListenerStrongly

public static boolean subscribeVetoListenerStrongly(java.lang.Class eventClass,
                                                    VetoEventListener vetoListener)
See Also:
EventService.subscribeVetoListenerStrongly(Class,VetoEventListener)

subscribeVetoListenerExactlyStrongly

public static boolean subscribeVetoListenerExactlyStrongly(java.lang.Class eventClass,
                                                           VetoEventListener vetoListener)
See Also:
EventService.subscribeVetoListenerExactlyStrongly(Class,VetoEventListener)

subscribeVetoListenerStrongly

public static boolean subscribeVetoListenerStrongly(java.lang.String topic,
                                                    VetoTopicEventListener vetoListener)
See Also:
EventService.subscribeVetoListenerStrongly(String,VetoTopicEventListener)

subscribeVetoListenerStrongly

public static boolean subscribeVetoListenerStrongly(java.util.regex.Pattern topicPattern,
                                                    VetoTopicEventListener vetoListener)
See Also:
EventService.subscribeVetoListener(String,VetoTopicEventListener)

unsubscribeVetoListener

public static boolean unsubscribeVetoListener(java.lang.Class eventClass,
                                              VetoEventListener vetoListener)
See Also:
EventService.unsubscribeVetoListener(Class,VetoEventListener)

unsubscribeVetoListenerExactly

public static boolean unsubscribeVetoListenerExactly(java.lang.Class eventClass,
                                                     VetoEventListener vetoListener)
See Also:
EventService.unsubscribeVetoListenerExactly(Class,VetoEventListener)

unsubscribeVetoListener

public static boolean unsubscribeVetoListener(java.lang.String topic,
                                              VetoTopicEventListener vetoListener)
See Also:
EventService.unsubscribeVetoListener(String,VetoTopicEventListener)

unsubscribeVetoListener

public static boolean unsubscribeVetoListener(java.util.regex.Pattern topicPattern,
                                              VetoTopicEventListener vetoListener)
See Also:
EventService.unsubscribeVetoListener(Pattern,VetoTopicEventListener)

getSubscribers

public static java.util.List getSubscribers(java.lang.Class eventClass)
See Also:
EventService.getSubscribers(Class)

getSubscribersToClass

public static java.util.List getSubscribersToClass(java.lang.Class eventClass)
See Also:
EventService.getSubscribersToClass(Class)

getSubscribersToExactClass

public static java.util.List getSubscribersToExactClass(java.lang.Class eventClass)
See Also:
EventService.getSubscribersToExactClass(Class)

getSubscribers

public static java.util.List getSubscribers(java.lang.String topic)
See Also:
EventService.getSubscribers(String)

getSubscribersToTopic

public static java.util.List getSubscribersToTopic(java.lang.String topic)
See Also:
EventService.getSubscribersToTopic(String)

getSubscribersByPattern

public static java.util.List getSubscribersByPattern(java.lang.String topic)
See Also:
EventService.getSubscribers(Class)

getVetoSubscribers

public static java.util.List getVetoSubscribers(java.lang.Class eventClass)
See Also:
EventService.getSubscribers(Class)

getVetoSubscribersToExactClass

public static java.util.List getVetoSubscribersToExactClass(java.lang.Class eventClass)
See Also:
EventService.getVetoSubscribersToExactClass(Class)

getVetoSubscribers

public static java.util.List getVetoSubscribers(java.lang.String topic)
See Also:
EventService.getVetoSubscribers(Class)

getVetoSubscribersToClass

public static java.util.List getVetoSubscribersToClass(java.lang.Class eventClass)
See Also:
EventService.getVetoSubscribersToClass(Class)

getVetoSubscribers

public static java.util.List getVetoSubscribers(java.util.regex.Pattern pattern)
See Also:
EventService.getVetoSubscribers(Pattern)

clearAllSubscribers

public static void clearAllSubscribers()
See Also:
EventService.clearAllSubscribers()

setDefaultCacheSizePerClassOrTopic

public static void setDefaultCacheSizePerClassOrTopic(int defaultCacheSizePerClassOrTopic)
See Also:
EventService.setDefaultCacheSizePerClassOrTopic(int)

getDefaultCacheSizePerClassOrTopic

public static int getDefaultCacheSizePerClassOrTopic()
See Also:
EventService.getDefaultCacheSizePerClassOrTopic()

setCacheSizeForEventClass

public static void setCacheSizeForEventClass(java.lang.Class eventClass,
                                             int cacheSize)
See Also:
EventService.setCacheSizeForEventClass(Class,int)

getCacheSizeForEventClass

public static int getCacheSizeForEventClass(java.lang.Class eventClass)
See Also:
EventService.getCacheSizeForEventClass(Class)

setCacheSizeForTopic

public static void setCacheSizeForTopic(java.lang.String topicName,
                                        int cacheSize)
See Also:
EventService.setCacheSizeForTopic(String,int)

setCacheSizeForTopic

public static void setCacheSizeForTopic(java.util.regex.Pattern pattern,
                                        int cacheSize)
See Also:
EventService.setCacheSizeForTopic(java.util.regex.Pattern,int)

getCacheSizeForTopic

public static int getCacheSizeForTopic(java.lang.String topic)
See Also:
EventService.getCacheSizeForTopic(String)

getLastEvent

public static java.lang.Object getLastEvent(java.lang.Class eventClass)
See Also:
EventService.getLastEvent(Class)

getCachedEvents

public static java.util.List getCachedEvents(java.lang.Class eventClass)
See Also:
EventService.getCachedEvents(Class)

getLastTopicData

public static java.lang.Object getLastTopicData(java.lang.String topic)
See Also:
EventService.getLastTopicData(String)

getCachedTopicData

public static java.util.List getCachedTopicData(java.lang.String topic)
See Also:
EventService.getCachedTopicData(String)

clearCache

public static void clearCache(java.lang.Class eventClass)
See Also:
EventService.clearCache(Class)

clearCache

public static void clearCache(java.lang.String topic)
See Also:
EventService.clearCache(String)

clearCache

public static void clearCache(java.util.regex.Pattern pattern)
See Also:
EventService.clearCache(java.util.regex.Pattern)

clearCache

public static void clearCache()
See Also:
EventService.clearCache()