org.mobicents.protocols.smpp.event
Class SimpleEventDispatcher

java.lang.Object
  extended by org.mobicents.protocols.smpp.event.AbstractEventDispatcher
      extended by org.mobicents.protocols.smpp.event.SimpleEventDispatcher
All Implemented Interfaces:
EventDispatcher

public class SimpleEventDispatcher
extends AbstractEventDispatcher

A simple implementation of the event dispatcher interface. This implementation simply iterates over the set of registered observers and notifies each of the event in turn. This means that whatever thread the Connection object uses to call into this object will be blocked, from the Connection's point of view, until every observer has successfully processed the event.

Adding and removing observers from an instance of this class is protected against multi-threaded access. However, event and packet notification is not. If an event notification is currently in progress and another thread modifies the set of registered observers, then it is possible for the new observer to receive events before the call to addObserver is complete.

Version:
$Id: SimpleEventDispatcher.java 457 2009-01-15 17:37:42Z orank $
See Also:
com.adenki.smpp.event.EventDispatcher

Constructor Summary
SimpleEventDispatcher()
          Create a new SimpleEventDispatcher.
SimpleEventDispatcher(SessionObserver observer)
          Create a new SimpleEventDispatcher and register one observer on it.
 
Method Summary
 void destroy()
          Event dispatcher clean up.
 void init()
          Initialise the event dispatcher.
 void notifyObservers(Session conn, SMPPEvent event)
          Notify registered observers of an SMPP event.
 void notifyObservers(Session conn, SMPPPacket packet)
          Notify registered observers of an incoming SMPP packet.
 
Methods inherited from class org.mobicents.protocols.smpp.event.AbstractEventDispatcher
addObserver, contains, getObserverList, getObservers, observerIterator, removeObserver, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleEventDispatcher

public SimpleEventDispatcher()
Create a new SimpleEventDispatcher.


SimpleEventDispatcher

public SimpleEventDispatcher(SessionObserver observer)
Create a new SimpleEventDispatcher and register one observer on it.

Method Detail

init

public void init()
Description copied from interface: EventDispatcher
Initialise the event dispatcher. The init method will be called by the Connection before it makes any attempt to add any observers or deliver any events via the dispatcher.


destroy

public void destroy()
Description copied from interface: EventDispatcher
Event dispatcher clean up. The destroy method will be called by the Connection when it is finished delivering events to it and the receiver daemon thread is exiting. Any initialising done in the init method can be cleaned up here.

The destroy method must not interfere with the delivery of any events notified to the event dispatcher before the call to this method.


notifyObservers

public void notifyObservers(Session conn,
                            SMPPEvent event)
Notify registered observers of an SMPP event.

Parameters:
conn - the Connection with which the event is associated.
event - the SMPP event to notify observers of.

notifyObservers

public void notifyObservers(Session conn,
                            SMPPPacket packet)
Notify registered observers of an incoming SMPP packet.

Parameters:
conn - the Connection which the packet was received on.
packet - the received packet to notify observers of.


Copyright © 2011 Mobicents. All Rights Reserved.