org.exoplatform.services.listener
Class ListenerService

java.lang.Object
  extended by org.exoplatform.services.listener.ListenerService

public class ListenerService
extends java.lang.Object

Created by The eXo Platform SAS Author : Nhu Dinh Thuan nhudinhthuan@exoplatform.com Apr 6, 2007


Constructor Summary
ListenerService()
          Construct a listener service.
 
Method Summary
 void addListener(Listener listener)
          This method is used to register a listener with the service.
 void addListener(java.lang.String eventName, Listener listener)
          Deprecated. use the Listener name as the event name
<S,D> void
broadcast(java.lang.String name, S source, D data)
          This method is used to broadcast an event.
<T extends Event>
void
broadcast(T event)
          This method is used when a developer want to implement his own event object and broadcast the event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListenerService

public ListenerService()
Construct a listener service.

Method Detail

addListener

public void addListener(Listener listener)
This method is used to register a listener with the service. The method should: 1. Check to see if there is a list of listener with the listener name, create one if the listener list doesn't exit 2. Add the new listener to the listener list

Parameters:
listener -

addListener

public void addListener(java.lang.String eventName,
                        Listener listener)
Deprecated. use the Listener name as the event name

Parameters:
eventName -
listener -

broadcast

public final <S,D> void broadcast(java.lang.String name,
                                  S source,
                                  D data)
                     throws java.lang.Exception
This method is used to broadcast an event. This method should: 1. Check if there is a list of listener that listen to the event name. 2. If there is a list of listener, create the event object with the given name , source and data 3. For each listener in the listener list, invoke the method onEvent(Event)

Type Parameters:
S - The type of the source that broacast the event
D - The type of the data that the source object is working on
Parameters:
name - The name of the event
source - The source object instance
data - The data object instance
Throws:
java.lang.Exception - TODO: Should not delegate to the method broadcast(Event)

broadcast

public final <T extends Event> void broadcast(T event)
                     throws java.lang.Exception
This method is used when a developer want to implement his own event object and broadcast the event. The method should: 1. Check if there is a list of listener that listen to the event name. 2. If there is a list of the listener, ror each listener in the listener list, invoke the method onEvent(Event)

Type Parameters:
T - The type of the event object, the type of the event object has to be extended from the Event type
Parameters:
event - The event instance
Throws:
java.lang.Exception


Copyright © 2012 eXo Platform SAS. All Rights Reserved.