Package org.apache.felix.framework.util
Class EventDispatcher
- java.lang.Object
-
- org.apache.felix.framework.util.EventDispatcher
-
public class EventDispatcher extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
EventDispatcher.Request
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<BundleContext,java.util.List<ListenerInfo>>
m_bndlListeners
private java.util.Map<BundleContext,java.util.List<ListenerInfo>>
m_fwkListeners
private Logger
m_logger
private static int
m_references
private ServiceRegistry
m_registry
private static java.util.List<EventDispatcher.Request>
m_requestList
private static java.util.List<EventDispatcher.Request>
m_requestPool
private static SecureAction
m_secureAction
private static boolean
m_stopping
private java.util.Map<BundleContext,java.util.List<ListenerInfo>>
m_svcListeners
private java.util.Map<BundleContext,java.util.List<ListenerInfo>>
m_syncBndlListeners
private static java.lang.Thread
m_thread
private static java.lang.String
m_threadLock
-
Constructor Summary
Constructors Constructor Description EventDispatcher(Logger logger, ServiceRegistry registry)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Filter
addListener(BundleContext bc, java.lang.Class clazz, java.util.EventListener l, Filter filter)
private static java.util.Map<BundleContext,java.util.List<ListenerInfo>>
addListenerInfo(java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners, ListenerInfo info)
private <T> java.util.Set<BundleContext>
createWhitelistFromHooks(java.util.EventObject event, Framework felix, java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners1, java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners2, java.lang.Class<T> hookClass)
private java.util.Map<BundleContext,java.util.List<ListenerInfo>>
filterListenersUsingHooks(ServiceEvent event, Framework felix, java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners)
void
fireBundleEvent(BundleEvent event, Framework felix)
private static void
fireEventAsynchronously(EventDispatcher dispatcher, int type, java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners, java.util.EventObject event)
private static void
fireEventImmediately(EventDispatcher dispatcher, int type, java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners, java.util.EventObject event, java.util.Dictionary oldProps)
void
fireFrameworkEvent(FrameworkEvent event)
void
fireServiceEvent(ServiceEvent event, java.util.Dictionary oldProps, Framework felix)
java.util.Collection<ListenerHook.ListenerInfo>
getAllServiceListeners()
Returns all existing service listener information into a collection of ListenerHook.ListenerInfo objects.private static void
invokeBundleListenerCallback(Bundle bundle, java.util.EventListener l, java.util.EventObject event)
private static void
invokeFrameworkListenerCallback(Bundle bundle, java.util.EventListener l, java.util.EventObject event)
private static void
invokeServiceListenerCallback(Bundle bundle, java.util.EventListener l, Filter filter, java.lang.Object acc, java.util.EventObject event, java.util.Dictionary oldProps)
ListenerHook.ListenerInfo
removeListener(BundleContext bc, java.lang.Class clazz, java.util.EventListener l)
private static java.util.Map<BundleContext,java.util.List<ListenerInfo>>
removeListenerInfo(java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners, BundleContext bc, int idx)
private static java.util.Map<BundleContext,java.util.List<ListenerInfo>>
removeListenerInfos(java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners, BundleContext bc)
void
removeListeners(BundleContext bc)
private static void
run()
This is the dispatching thread's main loop.void
startDispatching()
void
stopDispatching()
Filter
updateListener(BundleContext bc, java.lang.Class clazz, java.util.EventListener l, Filter filter)
private static java.util.Map<BundleContext,java.util.List<ListenerInfo>>
updateListenerInfo(java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners, int idx, ListenerInfo info)
-
-
-
Field Detail
-
m_logger
private final Logger m_logger
-
m_registry
private final ServiceRegistry m_registry
-
m_fwkListeners
private java.util.Map<BundleContext,java.util.List<ListenerInfo>> m_fwkListeners
-
m_bndlListeners
private java.util.Map<BundleContext,java.util.List<ListenerInfo>> m_bndlListeners
-
m_syncBndlListeners
private java.util.Map<BundleContext,java.util.List<ListenerInfo>> m_syncBndlListeners
-
m_svcListeners
private java.util.Map<BundleContext,java.util.List<ListenerInfo>> m_svcListeners
-
m_thread
private static java.lang.Thread m_thread
-
m_threadLock
private static final java.lang.String m_threadLock
-
m_references
private static int m_references
-
m_stopping
private static volatile boolean m_stopping
-
m_requestList
private static final java.util.List<EventDispatcher.Request> m_requestList
-
m_requestPool
private static final java.util.List<EventDispatcher.Request> m_requestPool
-
m_secureAction
private static final SecureAction m_secureAction
-
-
Constructor Detail
-
EventDispatcher
public EventDispatcher(Logger logger, ServiceRegistry registry)
-
-
Method Detail
-
startDispatching
public void startDispatching()
-
stopDispatching
public void stopDispatching()
-
addListener
public Filter addListener(BundleContext bc, java.lang.Class clazz, java.util.EventListener l, Filter filter)
-
removeListener
public ListenerHook.ListenerInfo removeListener(BundleContext bc, java.lang.Class clazz, java.util.EventListener l)
-
removeListeners
public void removeListeners(BundleContext bc)
-
updateListener
public Filter updateListener(BundleContext bc, java.lang.Class clazz, java.util.EventListener l, Filter filter)
-
getAllServiceListeners
public java.util.Collection<ListenerHook.ListenerInfo> getAllServiceListeners()
Returns all existing service listener information into a collection of ListenerHook.ListenerInfo objects. This is used the first time a listener hook is registered to synchronize it with the existing set of listeners.- Returns:
- Returns all existing service listener information into a collection of ListenerHook.ListenerInfo objects
-
fireFrameworkEvent
public void fireFrameworkEvent(FrameworkEvent event)
-
fireBundleEvent
public void fireBundleEvent(BundleEvent event, Framework felix)
-
fireServiceEvent
public void fireServiceEvent(ServiceEvent event, java.util.Dictionary oldProps, Framework felix)
-
filterListenersUsingHooks
private java.util.Map<BundleContext,java.util.List<ListenerInfo>> filterListenersUsingHooks(ServiceEvent event, Framework felix, java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners)
-
createWhitelistFromHooks
private <T> java.util.Set<BundleContext> createWhitelistFromHooks(java.util.EventObject event, Framework felix, java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners1, java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners2, java.lang.Class<T> hookClass)
-
fireEventAsynchronously
private static void fireEventAsynchronously(EventDispatcher dispatcher, int type, java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners, java.util.EventObject event)
-
fireEventImmediately
private static void fireEventImmediately(EventDispatcher dispatcher, int type, java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners, java.util.EventObject event, java.util.Dictionary oldProps)
-
invokeFrameworkListenerCallback
private static void invokeFrameworkListenerCallback(Bundle bundle, java.util.EventListener l, java.util.EventObject event)
-
invokeBundleListenerCallback
private static void invokeBundleListenerCallback(Bundle bundle, java.util.EventListener l, java.util.EventObject event)
-
invokeServiceListenerCallback
private static void invokeServiceListenerCallback(Bundle bundle, java.util.EventListener l, Filter filter, java.lang.Object acc, java.util.EventObject event, java.util.Dictionary oldProps)
-
addListenerInfo
private static java.util.Map<BundleContext,java.util.List<ListenerInfo>> addListenerInfo(java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners, ListenerInfo info)
-
updateListenerInfo
private static java.util.Map<BundleContext,java.util.List<ListenerInfo>> updateListenerInfo(java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners, int idx, ListenerInfo info)
-
removeListenerInfo
private static java.util.Map<BundleContext,java.util.List<ListenerInfo>> removeListenerInfo(java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners, BundleContext bc, int idx)
-
removeListenerInfos
private static java.util.Map<BundleContext,java.util.List<ListenerInfo>> removeListenerInfos(java.util.Map<BundleContext,java.util.List<ListenerInfo>> listeners, BundleContext bc)
-
run
private static void run()
This is the dispatching thread's main loop.
-
-