org.apache.felix.eventadmin.impl.handler
Class BlacklistingHandlerTasks

java.lang.Object
  extended by org.apache.felix.eventadmin.impl.handler.BlacklistingHandlerTasks
All Implemented Interfaces:
HandlerTasks

public class BlacklistingHandlerTasks
extends Object
implements HandlerTasks

This class is an implementation of the HandlerTasks interface that does provide blacklisting of event handlers. Furthermore, handlers are determined from the framework on any call to createHandlerTasks() hence, there is no book-keeping of EventHandler services while they come and go but a query for each sent event. In order to do this, an ldap-filter is created that will match applicable EventHandler references. In order to ease some of the overhead pains of this approach some light caching is going on.

Author:
Felix Project Team

Constructor Summary
BlacklistingHandlerTasks(org.osgi.framework.BundleContext context, BlackList blackList, TopicHandlerFilters topicHandlerFilters, Filters filters)
          The constructor of the factory.
 
Method Summary
 void blackList(org.osgi.framework.ServiceReference handlerRef)
          Blacklist the given service reference.
 List createHandlerTasks(org.osgi.service.event.Event event)
          Create the handler tasks for the event.
 org.osgi.service.event.EventHandler getEventHandler(org.osgi.framework.ServiceReference handlerRef)
          Get the real EventHandler service for the handlerRef from the context in case the ref is not blacklisted and the service is not unregistered.
 void ungetEventHandler(org.osgi.service.event.EventHandler handler, org.osgi.framework.ServiceReference handlerRef)
          Unget the service reference for the given event handler unless it is the NullEventHandler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlacklistingHandlerTasks

public BlacklistingHandlerTasks(org.osgi.framework.BundleContext context,
                                BlackList blackList,
                                TopicHandlerFilters topicHandlerFilters,
                                Filters filters)
The constructor of the factory.

Parameters:
context - The context of the bundle
blackList - The set to use for keeping track of blacklisted references
topicHandlerFilters - The factory for topic handler filters
filters - The factory for Filter objects
Method Detail

createHandlerTasks

public List createHandlerTasks(org.osgi.service.event.Event event)
Create the handler tasks for the event. All matching event handlers are determined and delivery tasks for them returned.

Specified by:
createHandlerTasks in interface HandlerTasks
Parameters:
event - The event for which' handlers delivery tasks must be created
Returns:
A delivery task for each handler that matches the given event
See Also:
HandlerTasks.createHandlerTasks(org.osgi.service.event.Event)

blackList

public void blackList(org.osgi.framework.ServiceReference handlerRef)
Blacklist the given service reference. This is a private method and only public due to its usage in a friend class.

Parameters:
handlerRef - The service reference to blacklist

getEventHandler

public org.osgi.service.event.EventHandler getEventHandler(org.osgi.framework.ServiceReference handlerRef)
Get the real EventHandler service for the handlerRef from the context in case the ref is not blacklisted and the service is not unregistered. The NullEventHandler object is returned otherwise. This is a private method and only public due to its usage in a friend class.

Parameters:
handlerRef - The service reference for which to get its service
Returns:
The service of the reference or a null object if the service is unregistered

ungetEventHandler

public void ungetEventHandler(org.osgi.service.event.EventHandler handler,
                              org.osgi.framework.ServiceReference handlerRef)
Unget the service reference for the given event handler unless it is the NullEventHandler. This is a private method and only public due to its usage in a friend class.

Parameters:
handler - The event handler service to unget
handlerRef - The service reference to unget


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.