org.activemath.events.impl
Class EventManager

java.lang.Object
  extended by org.activemath.events.impl.EventManager
All Implemented Interfaces:
ActivemathEventPublisher, ActivemathEventSubscriptionService

public class EventManager
extends Object
implements ActivemathEventPublisher, ActivemathEventSubscriptionService

Event Manager Singleton

The central place to publish events and subscribe listeners.

Version:
$Revision: 1.8 $

Field Summary
protected static Logger log
           
 
Constructor Summary
EventManager(Subconfiguration config)
           
 
Method Summary
static EventManager getInstance()
           
 XmlrpcEventService getService()
           
 void publishEvent(ActivemathEvent event)
          Publish an event to all subscribers.
 void subscribe(ActivemathEventListener listener)
          Subscribe a listener for all events.
 void subscribe(ActivemathEventListener listener, EventFilterList include, EventFilterList exclude)
          Subscribe a listener with an include and exclude event filter list.
 void unsubscribe(ActivemathEventListener listener)
          Unsubscribe a listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Logger log
Constructor Detail

EventManager

public EventManager(Subconfiguration config)
Method Detail

getInstance

public static EventManager getInstance()

getService

public XmlrpcEventService getService()

subscribe

public void subscribe(ActivemathEventListener listener)
Description copied from interface: ActivemathEventSubscriptionService
Subscribe a listener for all events.

This will replace any previous subscription of listener.

Specified by:
subscribe in interface ActivemathEventSubscriptionService

subscribe

public void subscribe(ActivemathEventListener listener,
                      EventFilterList include,
                      EventFilterList exclude)
Description copied from interface: ActivemathEventSubscriptionService
Subscribe a listener with an include and exclude event filter list.

Example usage for event filters:

            EventFilterList includeFilter = new EventFilterList();
            includeFilter.add(UserLoggedInEvent.EVENT_TYPE); // subscribe by String...
            includeFilter.add("ExerciseFinished"); // also by String
            includeFilter.add(UserLoggedOutEvent.class); // or subscribe by Class
            includeFilter.add(ItemEvent.class); // or subscribe by event tag
            EventManager.getInstance().subscribe(this, includeFilter, null);
 
This will replace any previous subscription of listener.

Specified by:
subscribe in interface ActivemathEventSubscriptionService
Parameters:
listener - - listener to send events to
include - - events to include, or null (will include all)
exclude - - events to exclude, or null (will exclude none)

unsubscribe

public void unsubscribe(ActivemathEventListener listener)
Description copied from interface: ActivemathEventSubscriptionService
Unsubscribe a listener.

Specified by:
unsubscribe in interface ActivemathEventSubscriptionService

publishEvent

public void publishEvent(ActivemathEvent event)
Publish an event to all subscribers. This also assigns the required unique id to the event before publishing it. We also assign the group id for all user events.

Specified by:
publishEvent in interface ActivemathEventPublisher