org.demac.impl.event
Class EventServiceImpl

java.lang.Object
  extended by org.demac.event.EventService
      extended by org.demac.impl.event.EventServiceImpl
All Implemented Interfaces:
Service, TransportListener

public class EventServiceImpl
extends EventService
implements TransportListener

TODO


Nested Class Summary
 class EventServiceImpl.EventHelper
           
 class EventServiceImpl.ForeignDispatcher
           
 class EventServiceImpl.LocalDispatcher
           
 
Method Summary
 void addEventListener(DeviceHandle dh, EventListener el, EventHandle eh)
          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.
 void addEventListener(EventListener listener, EventHandle eh)
          Method to register an org.demac.event.EventListener for a specific org.demac.event.Event at the EventService.
 void deviceDetected(Device device)
          This method is called when the org.demac.transport.TransportService detects a new device and adds it to it's list of new devices.
 void deviceRemoved(Device arg0)
          This method is called when the org.demac.transport.TransportService removes a device from the list of known devices.
 void dispatchEvent(Event ev)
          Method to trigger the dispatch of an org.demac.event.Event.
 void exceptionOccured(TransportException arg0)
          This method is called to inform the implementing object about ocurred org.demac.transport.TransportException[s].
static EventService getEventService()
           
 boolean isStarted()
          Method to determine whether the Service is started or not.
 void messageArrived(MessageHandle handle)
          By this method the implementing object is informed of an arrived message.
 void registerEventParser(EventHandle eh, java.lang.Class cl)
          Method to register a parser for a custom event.
 void removeEventListener(EventListener listener)
          Method to remove an org.demac.event.EventListener for all org.demac.event.Events from the EventService.
 void removeEventListener(EventListener listener, EventHandle eh)
          Method to remove an org.demac.event.EventListener for an specific org.demac.event.Event from the EventService.
 void start()
          Method to start the service.
 void stop()
          Method to stop the service.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getEventService

public static EventService getEventService()

addEventListener

public void addEventListener(DeviceHandle dh,
                             EventListener el,
                             EventHandle eh)
Description copied from class: EventService
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.

Specified by:
addEventListener in class EventService
Parameters:
dh - the handle of the device where to register the event
el - the listener to register

addEventListener

public void addEventListener(EventListener listener,
                             EventHandle eh)
Description copied from class: EventService
Method to register an org.demac.event.EventListener for a specific org.demac.event.Event at the EventService.

Specified by:
addEventListener in class EventService
Parameters:
listener - the listener to register
See Also:
org.demac.event.EventService#addEventListener(org.demac.event.EventListener, org.demac.event.Event)

removeEventListener

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

Specified by:
removeEventListener in class EventService
Parameters:
listener - the listener which should be removed from the service
See Also:
EventService.removeEventListener(org.demac.event.EventListener)

removeEventListener

public void removeEventListener(EventListener listener,
                                EventHandle eh)
Description copied from class: EventService
Method to remove an org.demac.event.EventListener for an specific org.demac.event.Event from the EventService.

Specified by:
removeEventListener in class EventService
Parameters:
listener - the listener which should be removed from the service
eh - the event for which the listener should be removed
See Also:
org.demac.event.EventService#removeEventListener(org.demac.event.EventListener, org.demac.event.Event)

dispatchEvent

public void dispatchEvent(Event ev)
Description copied from class: EventService
Method to trigger the dispatch of an org.demac.event.Event.

Specified by:
dispatchEvent in class EventService
Parameters:
ev - the event which is to be dispatched.
See Also:
EventService.dispatchEvent(org.demac.event.Event)

start

public void start()
Description copied from interface: Service
Method to start the service.

Specified by:
start in interface Service
See Also:
Service.start()

stop

public void stop()
Description copied from interface: Service
Method to stop the service.

Specified by:
stop in interface Service
See Also:
Service.stop()

messageArrived

public void messageArrived(MessageHandle handle)
Description copied from interface: TransportListener
By this method the implementing object is informed of an arrived message. The message is referenced by its org.demac.transport.MessageHandle.

Specified by:
messageArrived in interface TransportListener
Parameters:
handle - the handle of the arrived message
See Also:
TransportListener.messageArrived(org.demac.transport.MessageHandle)

deviceDetected

public void deviceDetected(Device device)
Description copied from interface: TransportListener
This method is called when the org.demac.transport.TransportService detects a new device and adds it to it's list of new devices.

Specified by:
deviceDetected in interface TransportListener
Parameters:
device - the device which was detected
See Also:
TransportListener.deviceDetected(org.demac.transport.Device)

registerEventParser

public void registerEventParser(EventHandle eh,
                                java.lang.Class cl)
                         throws java.lang.IllegalArgumentException
Description copied from class: EventService
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.

Specified by:
registerEventParser in class EventService
Parameters:
eh - the handle of the event that is assosiated to the parser
cl - 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

exceptionOccured

public void exceptionOccured(TransportException arg0)
Description copied from interface: TransportListener
This method is called to inform the implementing object about ocurred org.demac.transport.TransportException[s].

Specified by:
exceptionOccured in interface TransportListener
Parameters:
arg0 - the occured exception

deviceRemoved

public void deviceRemoved(Device arg0)
Description copied from interface: TransportListener
This method is called when the org.demac.transport.TransportService removes a device from the list of known devices.

Specified by:
deviceRemoved in interface TransportListener
Parameters:
arg0 - the device which was removed

isStarted

public boolean isStarted()
Description copied from interface: Service
Method to determine whether the Service is started or not.

Specified by:
isStarted in interface Service
Returns:
the status