|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.enhydra.barracuda.core.event.DefaultListenerFactory | +--org.enhydra.barracuda.core.event.helper.EventConnectorFactory
This class associates a specific event handler class with an event by extending DefaultListenerFactory and making implementation details in the gateways much simpler... Without this class, each instance of a listener factory must create a separate anonymous class and provide the implementation for getInstance() and getListenerID().
With this class, the association of an event to a handler is a reduced to a single line:
specifyLocalEventInterests(new EventConnectorFactory(Handler.class), Event.class);
IMPORTANT NOTE: When using this class, the passed-in event handler must
either be a non-inner class or an inner class which is declared public static.
Otherwise, when the getInstance() method attempts to instantiate the handler a
java.lang.InstantiationException
will get thrown which will show up
as a java.lang.NullPointerException
. This is because getInstance()
returns null if it fails to instantiate the handler. This won't be caught
at compile time, so be careful!
Field Summary | |
protected java.lang.Class |
eventHandlerClass
|
protected static org.apache.log4j.Logger |
logger
|
Fields inherited from class org.enhydra.barracuda.core.event.DefaultListenerFactory |
id |
Constructor Summary | |
EventConnectorFactory(java.lang.Class aClass)
Constructor |
Method Summary | |
BaseEventListener |
getInstance()
Get an instance of the underlying BaseEventListener |
java.lang.String |
getListenerID()
Get the Listener ID associated with this class of listener. |
Methods inherited from class org.enhydra.barracuda.core.event.DefaultListenerFactory |
getID, notifyAlways |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static org.apache.log4j.Logger logger
protected java.lang.Class eventHandlerClass
Constructor Detail |
public EventConnectorFactory(java.lang.Class aClass)
Method Detail |
public BaseEventListener getInstance()
getInstance
in interface ListenerFactory
getInstance
in class DefaultListenerFactory
public java.lang.String getListenerID()
getListenerID
in interface ListenerFactory
getListenerID
in class DefaultListenerFactory
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |