public class ListenerService extends Object
Listener
when a given event is broadcasted.| Modifier and Type | Class and Description |
|---|---|
protected class |
ListenerService.AsynchronousListener<S,D>
This AsynchronousListener is a wrapper for original listener, that
executes wrapped listeners onEvent() in separate thread.
|
protected class |
ListenerService.RunListener<S,D>
This thread executes listener.onEvent(event) method.
|
| Constructor and Description |
|---|
ListenerService(ExoContainerContext ctx)
Construct a listener service.
|
ListenerService(ExoContainerContext ctx,
InitialContextInitializer initializer)
Construct a listener service.
|
ListenerService(ExoContainerContext ctx,
InitialContextInitializer initializer,
InitParams params)
Construct a listener service.
|
ListenerService(ExoContainerContext ctx,
InitParams params)
Construct a listener service.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(Listener listener)
This method is used to register a
Listener to the events of the same
name. |
void |
addListener(String eventName,
Listener listener)
This method is used to register a new
Listener. |
<S,D> void |
broadcast(String name,
S source,
D data)
This method is used to broadcast an event.
|
<T extends Event> |
broadcast(T event)
This method is used when a developer want to implement his own event object
and broadcast the event.
|
public ListenerService(ExoContainerContext ctx)
public ListenerService(ExoContainerContext ctx, InitialContextInitializer initializer)
public ListenerService(ExoContainerContext ctx, InitParams params)
public ListenerService(ExoContainerContext ctx, InitialContextInitializer initializer, InitParams params)
public void addListener(Listener listener)
Listener to the events of the same
name. It is similar to addListener(listener.getName(), listener)listener - the listener to notify any time an even of the same name is
triggeredpublic void addListener(String eventName, Listener listener)
Listener. Any time an
event of the given event name has been triggered, the Listener will be
notified.
This method will:
eventName - The name of the event to listen tolistener - The Listener to notify any time the event with the given
name is triggeredpublic final <S,D> void broadcast(String name, S source, D data) throws Exception
S - The type of the source that broacast the eventD - The type of the data that the source object is working onname - The name of the eventsource - The source object instancedata - The data object instanceException - if an exception occurspublic final <T extends Event> void broadcast(T event) throws Exception
T - The type of the event object, the type of the event object has
to be extended from the Event typeevent - The event instanceExceptionCopyright © 2018 eXo Platform SAS. All Rights Reserved.