|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openbandy.service.Service
org.openbandy.service.EventService
public final class EventService
The EventService acts as a router between EventSources and EventSinks.
Events are either generated by event sources, which use this service
to dispatch the events to the subscribed sinks, or they can be created
by any other class or service.
The distinction of event types is made by the events shortClassName (@see
StringUtil), as for example 'ObjectEvent'.
As event sources are implemented as threads, we suggest to register every
source at the event service. This way it is possible to only start sources
when there actually is an event sink interest in the type of event provided.
Thus, as soon as an event sink is registered @ the event service, it tries to
start the needed event sources. If no sources are available, the event sink
stays registered and corresponding sources are started as soon as they are
registered at the event service. If an event source is unregistered that provided
an event type that is absorbed by a registered event sink, the affected
event sink will be informed via lostEventSource
.
(c) Copyright P. Bolliger 2007, ALL RIGHTS RESERVED.
Constructor Summary | |
---|---|
EventService()
|
Method Summary | |
---|---|
static void |
dispatch(Event event)
This methods forwards the provided Event to every EventSink that has been registered for this type of Event. |
static void |
registerSource(EventSource eventSource)
This method registers an EventSource with every type of event it provides. |
static void |
subscribe(EventSink eventSink,
EventFilter filter)
This method registers an EventSink with every type of event it absorbs. |
static void |
unregisterSource(EventSource eventSource)
Unregister an EventSource. |
static void |
unsubscribe(EventSink eventSink)
Unsubscribe an EventSink. |
Methods inherited from class org.openbandy.service.Service |
---|
runningOnMicroEdition, runningOnSunWTK |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public EventService()
Method Detail |
---|
public static void registerSource(EventSource eventSource)
eventSource
- The source to register.public static void subscribe(EventSink eventSink, EventFilter filter)
eventSink
- The sink to register.public static void unregisterSource(EventSource eventSource)
eventSource
- The source to unregister.public static void unsubscribe(EventSink eventSink)
eventSink
- The sink to unregister.public static void dispatch(Event event)
event
- The event that has to be routed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |