org.demac.event
Class EventService

java.lang.Object
  extended by org.demac.event.EventService
All Implemented Interfaces:
Service
Direct Known Subclasses:
EventServiceImpl

public abstract class EventService
extends java.lang.Object
implements Service

The generic event service of the DEMAC architecture.


Constructor Summary
EventService()
           
 
Method Summary
abstract  void addEventListener(DeviceHandle device, EventListener listener, EventHandle eventHandle)
          Method to register an org.demac.event.EventListener for a specific org.demac.event.Event at the EventService of a local or remote org.demac.Device.
abstract  void addEventListener(EventListener listener, EventHandle eventHandle)
          Method to register an org.demac.event.EventListener for a specific org.demac.event.Event at the EventService.
abstract  void dispatchEvent(Event event)
          Method to trigger the dispatch of an org.demac.event.Event.
static EventService getEventService()
          Method to get an instance of the DEMAC event service.
abstract  void registerEventParser(EventHandle eventHandle, java.lang.Class parser)
          Method to register a parser for a custom event.
abstract  void removeEventListener(EventListener listener)
          Method to remove an org.demac.event.EventListener for all org.demac.event.Events from the EventService.
abstract  void removeEventListener(EventListener listener, EventHandle event)
          Method to remove an org.demac.event.EventListener for an specific org.demac.event.Event from the EventService.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.demac.Service
isStarted, start, stop
 

Constructor Detail

EventService

public EventService()
Method Detail

getEventService

public static EventService getEventService()
Method to get an instance of the DEMAC event service. As mobile devices are mostly limited in their computing power the EventService should be implemented as a singleton. This method should provide access to the instance of the event service.

Returns:
the instance of the event service

addEventListener

public abstract void addEventListener(EventListener listener,
                                      EventHandle eventHandle)
Method to register an org.demac.event.EventListener for a specific org.demac.event.Event at the EventService.

Parameters:
listener - the listener to register
event - the event handle which should be send to the listener

addEventListener

public abstract void addEventListener(DeviceHandle device,
                                      EventListener listener,
                                      EventHandle eventHandle)
Method to register an org.demac.event.EventListener for a specific org.demac.event.Event at the EventService of a local or remote org.demac.Device.

Parameters:
device - the handle of the device where to register the event
listener - the listener to register
event - the event handle which should be send to the listener

removeEventListener

public abstract void removeEventListener(EventListener listener)
Method to remove an org.demac.event.EventListener for all org.demac.event.Events from the EventService.

Parameters:
listener - the listener which should be removed from the service

removeEventListener

public abstract void removeEventListener(EventListener listener,
                                         EventHandle event)
Method to remove an org.demac.event.EventListener for an specific org.demac.event.Event from the EventService.

Parameters:
listener - the listener which should be removed from the service
event - the event for which the listener should be removed

dispatchEvent

public abstract void dispatchEvent(Event event)
Method to trigger the dispatch of an org.demac.event.Event.

Parameters:
event - the event which is to be dispatched.

registerEventParser

public abstract void registerEventParser(EventHandle eventHandle,
                                         java.lang.Class parser)
                                  throws java.lang.IllegalArgumentException
Method to register a parser for a custom event. The event is identified by it's unique org.demac.event.EventHandle and the parser must have an empty constructor and must implement the org.demac.event.EventParser interface.

Parameters:
eventHandle - the handle of the event that is assosiated to the parser
parser - the parser for the associated event
Throws:
java.lang.IllegalArgumentException - if the associated parser class does not implement the interface org.demac.event.EventParser or does not have an empty constructor