|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.barracudamvc.core.event.DefaultListenerFactory
org.barracudamvc.core.event.helper.EventConnectorFactory
public class 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 Class |
eventHandlerClass
|
protected static org.apache.log4j.Logger |
logger
|
Fields inherited from class org.barracudamvc.core.event.DefaultListenerFactory |
---|
id |
Constructor Summary | |
---|---|
EventConnectorFactory(Class aClass)
Constructor |
Method Summary | |
---|---|
BaseEventListener |
getInstance()
Get an instance of the underlying BaseEventListener |
String |
getListenerID()
Get the Listener ID associated with this class of listener. |
Methods inherited from class org.barracudamvc.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 final org.apache.log4j.Logger logger
protected Class eventHandlerClass
Constructor Detail |
---|
public EventConnectorFactory(Class aClass)
aClass
- the handler class to associate with an eventMethod Detail |
---|
public BaseEventListener getInstance()
getInstance
in interface ListenerFactory
getInstance
in class DefaultListenerFactory
public 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 |