|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.mmm.util.component.base.AbstractComponent
net.sf.mmm.util.component.base.AbstractLoggableComponent
net.sf.mmm.util.event.base.AbstractEventSource<E,L>
E - is the templated type of the events to send.L - is the templated type of the listeners that can be
registered here and that will
receive the sent events.public abstract class AbstractEventSource<E extends Event,L extends EventListener<E>>
This is the abstract base implementation of the
EventListener interface.
| Field Summary | |
|---|---|
private Collection<L> |
listeners
the registered listeners |
| Constructor Summary | |
|---|---|
|
AbstractEventSource()
The constructor. |
protected |
AbstractEventSource(CollectionFactory<? extends Collection> collectionFactory)
The constructor. |
| Method Summary | |
|---|---|
void |
addListener(L listener)
This method registers a listener that is interested in Events. |
protected void |
fireEvent(E event)
This method sends the given event to all
registered listeners. |
protected void |
fireEvent(E event,
L listener)
This method sends the given event to the given
listener. |
protected void |
handleListenerError(L listener,
E event,
Throwable error)
This method is called if a listener throws something while handling an event. |
boolean |
removeListener(L listener)
This method removes a listener. |
| Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent |
|---|
doInitialize, getLogger, setLogger |
| Methods inherited from class net.sf.mmm.util.component.base.AbstractComponent |
|---|
doInitialized, getInitializationState, initialize |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final Collection<L extends EventListener<E>> listeners
| Constructor Detail |
|---|
public AbstractEventSource()
protected AbstractEventSource(CollectionFactory<? extends Collection> collectionFactory)
collectionFactory - is the collection factory used to create the
internal Collection for the listeners.| Method Detail |
|---|
public void addListener(L listener)
Events.
addListener in interface EventSource<E extends Event,L extends EventListener<E>>listener - is the listener to add.public boolean removeListener(L listener)
removeListener in interface EventSource<E extends Event,L extends EventListener<E>>listener - is the listener to remove.
true if the given listener has
successfully been removed, false if the
listener was NOT registered.protected void fireEvent(E event)
event to all
registered listeners.
event - the event to set.
protected void fireEvent(E event,
L listener)
event to the given
listener.
event - the event to set.listener - the listener that should receive the event.
protected void handleListenerError(L listener,
E event,
Throwable error)
listener - is the listener that caused the error.event - is the event that could not be handled.error - is the throwable caused by the listener while
handling the event.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||