public interface EventStudio
EventStudio is a thread-safe central place allowing broadcast of events to Listeners to registered on a Station. Stations are created internally as soon as a
listener is added but it's up to the user to clear a station when it's not needed anymore. Listeners can be added multiple times either to different or the same station
and they will be called as many times as they have been added.
As a general rule null parameters are not allowed (either station names, listeners, supervisors.. )
| Modifier and Type | Field and Description |
|---|---|
static String |
MAX_QUEUE_SIZE_PROP |
| Modifier and Type | Method and Description |
|---|---|
<T> void |
add(Class<T> eventClass,
Listener<T> listener,
String station)
Adds the given
Listener, listening for the given event class, to the given station using default priority(0) ad default strength ReferenceStrength.STRONG. |
<T> void |
add(Class<T> eventClass,
Listener<T> listener,
String station,
int priority,
ReferenceStrength strength)
Adds the given
Listener, listening for the given event class, to the given station using the given priority (low values mean higher priority) and strength. |
<T> void |
add(Listener<T> listener,
String station)
Adds the given
Listener to the given station using default priority(0) ad default strength ReferenceStrength.STRONG. |
<T> void |
add(Listener<T> listener,
String station,
int priority,
ReferenceStrength strength)
Adds the given
Listener to the given station using the given priority (low values mean higher priority) and strength. |
void |
addAnnotatedListeners(Object bean)
Discovers annotated method on the the given bean and adds them as
Listeners |
void |
broadcast(Object event,
String station)
Broadcasts the given event to the given station.
|
void |
broadcastToEveryStation(Object event)
Broadcasts the given event to every station.
|
void |
clear(String station)
Clear the given station removing the whole station from the
EventStudio which means that Listeners and Supervisor will not be notified anymore. |
<T> boolean |
remove(Class<T> eventClass,
Listener<T> listener,
String station)
Removes the first occurrence of the given
Listener listening for the given event, from the given station |
<T> boolean |
remove(Listener<T> listener,
String station)
Removes the first occurrence of the given
Listener from the given station. |
<T> void |
supervisor(Supervisor supervisor,
String station)
Sets a
Supervisor for the given station. |
static final String MAX_QUEUE_SIZE_PROP
<T> void add(Listener<T> listener, String station)
Listener to the given station using default priority(0) ad default strength ReferenceStrength.STRONG.<T> void add(Listener<T> listener, String station, int priority, ReferenceStrength strength)
Listener to the given station using the given priority (low values mean higher priority) and strength.<T> void add(Class<T> eventClass, Listener<T> listener, String station)
Listener, listening for the given event class, to the given station using default priority(0) ad default strength ReferenceStrength.STRONG.
This add method is useful when a listener can listen for a hierarchy of events.<T> void add(Class<T> eventClass, Listener<T> listener, String station, int priority, ReferenceStrength strength)
Listener, listening for the given event class, to the given station using the given priority (low values mean higher priority) and strength. This add
method is useful when a listener can listen for a hierarchy of events:
class BroadListener{@code <T extends ParentEvent> implements Listener<T>} {
void onEvent(ParentEvent e){
LOG.debug(e);
}
}
class X {
public void init() {
EventStudio studio = ....
studio.add(ChildEvent.class, new BroadListener{@code <ChildEvent>}(), "mystation");
studio.add(AnotherChildEvent.class, new BroadListener{@code <AnotherChildEvent>()}, "mystation");
...
}
}
void addAnnotatedListeners(Object bean)
Listenersbean - EventListener,
EventStation<T> void supervisor(Supervisor supervisor, String station)
Supervisor for the given station. It will be notified of every event broadcasted to the station prior its delivery to the proper Listeners allowing
event inspection.
Supervisors cannot be removed but they can be replaces. See Supervisor.SLACKER
<T> boolean remove(Listener<T> listener, String station)
Listener from the given station.<T> boolean remove(Class<T> eventClass, Listener<T> listener, String station)
Listener listening for the given event, from the given stationvoid clear(String station)
EventStudio which means that Listeners and Supervisor will not be notified anymore. A
station with the same name can be recreated.void broadcast(Object event, String station)
Listeners listening the given station and bound to the event class will be notified.Copyright © 2020 Sober Lemur S.a.s. di Vacondio Andrea. All rights reserved.