org.apache.felix.ipojo
Class EventDispatcher

java.lang.Object
  extended by org.apache.felix.ipojo.EventDispatcher
All Implemented Interfaces:
EventListener, ServiceListener

public final class EventDispatcher
extends Object
implements ServiceListener

iPOJO Internal event dispatcher. This class provides an internal service event dispatcher in order to tackle the event storm that can happen when starting large-scale applications.

Author:
Felix Project Team
See Also:
Extender

Method Summary
 void addListener(String itf, ServiceListener listener)
          Adds a new service listener to the m_listeners map.
static void create(BundleContext bc)
          Creates the internal event dispatcher.
static void dispose()
          Stops and delete the internal event dispatcher.
static EventDispatcher getDispatcher()
          Gets the iPOJO event dispatcher.
 boolean removeListener(ServiceListener listener)
          Removes a service listener.
 void serviceChanged(ServiceEvent event)
          Method called when a ServiceEvent is fired by the OSGi framework.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static void create(BundleContext bc)
Creates the internal event dispatcher.

Parameters:
bc - the iPOJO bundle context to send to the internal event dispatcher.

dispose

public static void dispose()
Stops and delete the internal event dispatcher. This method must be call only if iPOJO is stopping.


getDispatcher

public static EventDispatcher getDispatcher()
Gets the iPOJO event dispatcher.

Returns:
the event dispatcher or null if not created.

serviceChanged

public void serviceChanged(ServiceEvent event)
Method called when a ServiceEvent is fired by the OSGi framework. According to the event, this method dispatches to interested registered listers from the m_listeners map.

Specified by:
serviceChanged in interface ServiceListener
Parameters:
event - the service event
See Also:
ServiceListener.serviceChanged(org.osgi.framework.ServiceEvent)

addListener

public void addListener(String itf,
                        ServiceListener listener)
Adds a new service listener to the m_listeners map. This method specifies the listen service interface

Parameters:
itf - the service interface
listener - the service listener

removeListener

public boolean removeListener(ServiceListener listener)
Removes a service listener.

Parameters:
listener - the service listener to remove
Returns:
true if the listener is successfully removed.


Copyright © 2011 Apache Software Foundation. All Rights Reserved.