public class EventServiceLocator extends Object
EventBus
.
By default will lazily hold a SwingEventService, which is mapped to SERVICE_NAME_SWING_EVENT_SERVICE
and
returned by getSwingEventService()
. Also by default this same instance is returned by getEventBusService()
,
is mapped to SERVICE_NAME_EVENT_BUS
and wrapped by the EventBus.
Since the default EventService implementation is thread safe, and since it's not good to have lots of events on the
EventDispatchThread you may want multiple EventServices running on multiple threads, perhaps pulling events from a
server and coalescing them into one or more events that are pushed onto the EDT.
To change the default implementation class for the EventBus' EventService, use the API:
EventServiceLocator.setEventService(EventServiceLocator.SERVICE_NAME_EVENT_BUS, new SomeEventServiceImpl());Or use system properties by:
System.setProperty(EventServiceLocator.SERVICE_NAME_EVENT_BUS, YourEventServiceImpl.class.getName());Likewise, you can set this on the command line via -Dorg.bushe.swing.event.swingEventServiceClass=foo.YourEventServiceImpl To change the default implementation class for the SwingEventService, use the API:
EventServiceLocator.setEventService(EventServiceLocator.SERVICE_NAME_SWING_EVENT_SERVICE, new SomeSwingEventServiceImpl());Or use system properties by:
System.setProperty(EventServiceLocator.SWING_EVENT_SERVICE_CLASS, YourEventServiceImpl.class.getName());Likewise, you can set this on the command line via -Dorg.bushe.swing.event.swingEventServiceClass=foo.YourEventServiceImpl
Modifier and Type | Field and Description |
---|---|
static String |
EVENT_BUS_CLASS
Set this Java property to a Class that implements EventService to use an instance of that class instead of
the instance returned by
getSwingEventService() . |
static String |
SERVICE_NAME_EVENT_BUS
The name "EventBus" is reserved for the service that the EventBus wraps and is returned by
getEventBusService() . |
static String |
SERVICE_NAME_SWING_EVENT_SERVICE
The name "SwingEventService" is reserved for the service that is returned by
getSwingEventService() . |
static String |
SWING_EVENT_SERVICE_CLASS
Set this Java property to a Class that implements EventService to use an instance of that class instead of
SwingEventService as service returned by getSwingEventService() . |
Constructor and Description |
---|
EventServiceLocator() |
Modifier and Type | Method and Description |
---|---|
static EventService |
getEventBusService() |
static EventService |
getEventService(String serviceName) |
static EventService |
getSwingEventService() |
static void |
setEventService(String serviceName,
EventService es)
Registers a named EventService to the locator.
|
public static final String SERVICE_NAME_EVENT_BUS
getEventBusService()
.public static final String SERVICE_NAME_SWING_EVENT_SERVICE
getSwingEventService()
.public static final String EVENT_BUS_CLASS
getSwingEventService()
. Must be set before getEventBusService()
is called.public static final String SWING_EVENT_SERVICE_CLASS
SwingEventService
as service returned by getSwingEventService()
. Must be set on startup or
before the method getSwingEventService()
is called.public static EventService getEventBusService()
public static EventService getSwingEventService()
public static EventService getEventService(String serviceName)
serviceName
- the service name of the EventService, as registered by #setEventService(String, EventService),
or SERVICE_NAME_EVENT_BUS
or SERVICE_NAME_SWING_EVENT_SERVICE
.public static void setEventService(String serviceName, EventService es) throws EventServiceExistsException
serviceName
- a named event service instancees
- the EventService to attach to the service nameEventServiceExistsException
- if a service by this name already exists and the new service is non-nullCopyright © 2013 Bushe Enterprises, Inc.. All rights reserved.