net.sf.mmm.util.event.base
Class AbstractMultiThreadedEventSource<E extends Event,L extends EventListener<E>>

java.lang.Object
  extended by net.sf.mmm.util.component.base.AbstractComponent
      extended by net.sf.mmm.util.component.base.AbstractLoggableComponent
          extended by net.sf.mmm.util.event.base.AbstractEventSource<E,L>
              extended by net.sf.mmm.util.event.base.AbstractSynchronizedEventSource<E,L>
                  extended by net.sf.mmm.util.event.base.AbstractMultiThreadedEventSource<E,L>
Type Parameters:
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.
All Implemented Interfaces:
EventSource<E,L>

public abstract class AbstractMultiThreadedEventSource<E extends Event,L extends EventListener<E>>
extends AbstractSynchronizedEventSource<E,L>

This class extends AbstractSynchronizedEventSource with the ability to send events asynchronous in separate Threads.

Since:
1.0.1
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
private  Executor executor
           
 
Constructor Summary
AbstractMultiThreadedEventSource()
          The constructor.
 
Method Summary
protected  void doInitialize()
          This method performs the actual initialization.
protected  void fireEvent(E event, L listener)
          This method sends the given event to the given listener.
 Executor getExecutor()
          This method gets the Executor used to run asynchronous tasks.
 void setExecutor(Executor threadPool)
          This method sets the executor to use.
 
Methods inherited from class net.sf.mmm.util.event.base.AbstractEventSource
addListener, fireEvent, handleListenerError, removeListener
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent
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

executor

private Executor executor
See Also:
getExecutor()
Constructor Detail

AbstractMultiThreadedEventSource

public AbstractMultiThreadedEventSource()
The constructor.

Method Detail

setExecutor

@Inject
public void setExecutor(Executor threadPool)
This method sets the executor to use.

Parameters:
threadPool - is used to dispatch events in separate threads.

getExecutor

public Executor getExecutor()
This method gets the Executor used to run asynchronous tasks. It may use a thread-pool.

Returns:
the executor.

doInitialize

protected void doInitialize()
This method performs the actual initialization. It is called when AbstractComponent.initialize() is invoked for the first time.
ATTENTION:
When you override this method from a sub-class you need to do a super.AbstractComponent.doInitialize().

Overrides:
doInitialize in class AbstractLoggableComponent

fireEvent

protected void fireEvent(E event,
                         L listener)
This method sends the given event to the given listener.

Overrides:
fireEvent in class AbstractEventSource<E extends Event,L extends EventListener<E>>
Parameters:
event - the event to set.
listener - the listener that should receive the event.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.