fulmine.event
Interface IEventSource

All Superinterfaces:
IAddressable, IDescriptor, IDestroyable, ILifeCycle
All Known Subinterfaces:
IComponent, IConnection, IContainer, IContainerDefinitionField, IField, ISystemEventSource
All Known Implementing Classes:
AbstractComponent, AbstractContainer, AbstractDynamicContainer, AbstractEventProcessingContainer, AbstractField, AbstractSocketChannelConnection, ActiveAsymmetricEventProcessor, AsymmetricEventProcessor, BasicContainer, BooleanField, ContainerDefinitionField, DescriptorField, DoubleField, EventSource, FloatField, ImageEvent, IntegerField, LongField, Record, StringField, SystemEventSource, TcpConnection

public interface IEventSource
extends IDescriptor, ILifeCycle, IAddressable

An object that generates IEvent objects. The events are distributed to IEventListener instances. The listeners need to be registered with the source via the addListener(IEventListener) method.

Author:
Ramon Servadei

Method Summary
 void addEvent(IEvent event)
          Add the event to the source and notify any registered IEventListener instances with the event.
 boolean addListener(IEventListener listener)
          Add the listener to the end of the list of listeners registered against this.
 byte getEventSourceGroupId()
          A byte identifying the event source group id.
 List<IEventListener> getListeners()
          Get the list of IEventListener instances observing this.
 boolean removeListener(IEventListener listener)
          Remove the listener from the list of listeners registered against this.
 List<IEventListener> removeListeners()
          Remove all listeners registered for receiving IEvent events originating from this.
 
Methods inherited from interface fulmine.IDescriptor
toDetailedString, toIdentityString
 
Methods inherited from interface fulmine.ILifeCycle
isActive, start
 
Methods inherited from interface fulmine.IDestroyable
destroy
 
Methods inherited from interface fulmine.IAddressable
getAddress, getDomain, getIdentity, getType
 

Method Detail

getListeners

List<IEventListener> getListeners()
Get the list of IEventListener instances observing this. The list is the order of registration and the notification order for any IEvent raised by this event source.

The list is not modifiable.

Returns:
an unmodifiable list of listeners, or null if there are no listeners

addListener

boolean addListener(IEventListener listener)
Add the listener to the end of the list of listeners registered against this. If the listener is an IPriorityEventListener, it is added to the beginning of the list.

Listeners are reference counted. Adding the same listener multiple times simply increments a reference count of the listener instance; if a listener is added twice, it must be removed twice for the listener instance reference to be removed from the internal list.

Parameters:
listener - the listener to add
Returns:
true if the listener instance was added (there were no reference counts for it), false if it already existed (the reference count was incremented)

removeListener

boolean removeListener(IEventListener listener)
Remove the listener from the list of listeners registered against this. If this is the last listener being removed, the list of listeners is set to null.

Listeners are reference counted. When removing a listener, this method decrements the reference count until there are no more references, at which point the listener instance reference is actually removed.

Parameters:
listener - the listener to remove
Returns:
true if the listener was found and the reference count was 0 and it was removed, false otherwise

removeListeners

List<IEventListener> removeListeners()
Remove all listeners registered for receiving IEvent events originating from this.

Returns:
the list of listeners removed

getEventSourceGroupId

byte getEventSourceGroupId()
A byte identifying the event source group id. This will be the id of the EventProcessor that will distribute the events from this source.

Returns:
a byte for the EventProcessor servicing this.

addEvent

void addEvent(IEvent event)
Add the event to the source and notify any registered IEventListener instances with the event. The manner of activating listeners with the event may be synchronous or asynchronous; it is the implementation that decides this.

Parameters:
event - the event to pass on to the registered listeners


Copyright © 2007-2009. All Rights Reserved.