org.apache.felix.ipojo

## Class EventDispatcher

- java.lang.Object
- - org.apache.felix.ipojo.EventDispatcher

All Implemented Interfaces:
  java.util.EventListener, org.osgi.framework.ServiceListener

    public final class EventDispatcher
    extends java.lang.Object
    implements org.osgi.framework.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:
  `ServiceListener`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `addListener(java.lang.String itf, org.osgi.framework.ServiceListener listener)` Adds a new service listener to the `m_listeners` map.
`static void` `create(org.osgi.framework.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(org.osgi.framework.ServiceListener listener)` Removes a service listener.
`void` `serviceChanged(org.osgi.framework.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(org.osgi.framework.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(org.osgi.framework.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 `org.osgi.framework.ServiceListener`
Parameters:
  `event` - the service event
See Also:
  `ServiceListener.serviceChanged(org.osgi.framework.ServiceEvent)`

#### addListener

    public void addListener(java.lang.String itf,
                            org.osgi.framework.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(org.osgi.framework.ServiceListener listener)

Removes a service listener.

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