public class ListenerService extends Object implements org.picocontainer.Startable
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(org.exoplatform.container.ExoContainerContext ctx)
Construct a listener service.
|
ListenerService(org.exoplatform.container.ExoContainerContext ctx,
InitialContextInitializer initializer)
Construct a listener service.
|
ListenerService(org.exoplatform.container.ExoContainerContext ctx,
InitialContextInitializer initializer,
org.exoplatform.container.xml.InitParams params)
Construct a listener service.
|
ListenerService(org.exoplatform.container.ExoContainerContext ctx,
org.exoplatform.container.xml.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 org.exoplatform.services.listener.Event> |
broadcast(T event)
This method is used when a developer want to implement his own event object
and broadcast the event.
|
void |
start() |
void |
stop() |
public ListenerService(org.exoplatform.container.ExoContainerContext ctx)
public ListenerService(org.exoplatform.container.ExoContainerContext ctx, InitialContextInitializer initializer)
public ListenerService(org.exoplatform.container.ExoContainerContext ctx, org.exoplatform.container.xml.InitParams params)
public ListenerService(org.exoplatform.container.ExoContainerContext ctx, InitialContextInitializer initializer, org.exoplatform.container.xml.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 org.exoplatform.services.listener.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 instanceException
public void start()
start
in interface org.picocontainer.Startable
public void stop()
stop
in interface org.picocontainer.Startable
Copyright © 2003–2019 eXo Platform SAS. All rights reserved.