cz.cuni.amis.pogamut.base.communication.worldview.listener.annotation
Class AnnotationListenerRegistrator

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.communication.worldview.listener.annotation.AnnotationListenerRegistrator
All Implemented Interfaces:
IListenerRegistrator

public class AnnotationListenerRegistrator
extends java.lang.Object
implements IListenerRegistrator

The registrator that is driven by annotations on the class it introspects.

WARNING: the inheritance does not work here! Only the top class object is introspected.


Constructor Summary
AnnotationListenerRegistrator(java.lang.Object obj, IWorldView worldView, java.util.logging.Logger log)
           
 
Method Summary
 void addListeners()
          Introspect all object's methods and register various listeners based on EventListener, etc...
static WorldObjectId getId(java.lang.reflect.Method method, ObjectEventListener annotation)
          Returns a new WorldObjectId for the given 'annotation'.
static WorldObjectId getId(java.lang.reflect.Method method, ObjectListener annotation)
          Returns a new WorldObjectId for the given 'annotation'.
static ListenerLevel getListenerLevel(java.lang.reflect.Method method)
          Returns listener level that is gained from the method's annotation.
 int getListenersCount()
           
 void removeListeners()
          Removes (unregister) all the listeners the registrator has created.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationListenerRegistrator

public AnnotationListenerRegistrator(java.lang.Object obj,
                                     IWorldView worldView,
                                     java.util.logging.Logger log)
Method Detail

getId

public static WorldObjectId getId(java.lang.reflect.Method method,
                                  ObjectListener annotation)
Returns a new WorldObjectId for the given 'annotation'.

Parameters:
method -
annotation -
Returns:
id instance

getId

public static WorldObjectId getId(java.lang.reflect.Method method,
                                  ObjectEventListener annotation)
Returns a new WorldObjectId for the given 'annotation'.

Parameters:
method -
annotation -
Returns:
id instance

getListenerLevel

public static ListenerLevel getListenerLevel(java.lang.reflect.Method method)
Returns listener level that is gained from the method's annotation.

Parameters:
method -
Returns:
listener level of the method

addListeners

public void addListeners()
                  throws ListenersAlreadyRegisteredException
Introspect all object's methods and register various listeners based on EventListener, etc... annotations.

Specified by:
addListeners in interface IListenerRegistrator
Parameters:
obj -
Throws:
ListenersAlreadyRegisteredException

getListenersCount

public int getListenersCount()

removeListeners

public void removeListeners()
Description copied from interface: IListenerRegistrator
Removes (unregister) all the listeners the registrator has created.

Specified by:
removeListeners in interface IListenerRegistrator