org.ungoverned.oscar.util
Class OscarDispatchQueue

java.lang.Object
  extended by org.ungoverned.oscar.util.DispatchQueue
      extended by org.ungoverned.oscar.util.OscarDispatchQueue

public class OscarDispatchQueue
extends DispatchQueue

This is a subclass of DispatchQueue that specifically adds support for SynchronousBundleListeners; the OSGi specification says that synchronous bundle listeners should receive their events immediately, i.e., they should not be delivered on a separate thread like is the case with the DispatchQueue. To achieve this functionality, this class overrides the dispatch method to automatically fire any bundle events to synchronous bundle listeners using the calling thread. In order to ensure that synchronous bundle listeners do not receive an event twice, it wraps the passed in Dipatcher instance so that it filters synchronous bundle listeners.


Constructor Summary
OscarDispatchQueue()
           
 
Method Summary
 void dispatch(Dispatcher dispatcher, java.lang.Class clazz, java.util.EventObject eventObj)
          Dispatches an event to a set of event listeners using a specified dispatcher object.
 
Methods inherited from class org.ungoverned.oscar.util.DispatchQueue
addListener, dispatch, getListener, getListeners, removeListener, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OscarDispatchQueue

public OscarDispatchQueue()
Method Detail

dispatch

public void dispatch(Dispatcher dispatcher,
                     java.lang.Class clazz,
                     java.util.EventObject eventObj)
Dispatches an event to a set of event listeners using a specified dispatcher object. This overrides the definition of the super class to deliver events to ServiceListeners and SynchronousBundleListeners using the calling thread instead of the event dispatching thread. All other events are still delivered asynchronously.

Overrides:
dispatch in class DispatchQueue
Parameters:
dispatcher - the dispatcher used to actually dispatch the event; this varies according to the type of event listener.
clazz - the class associated with the target event listener type; only event listeners of this type will receive the event.
eventObj - the actual event object to dispatch.