Search code examples
event-handlingaemapache-felixsling

How to avoid blacklisting my eventhandler through Apache Felix Event Admin Implementation


Standard timeout of Apache Felix Event Admin Implementation in felix->configuration is 5000ms. Now how to allow one or more event handler to take longer time (with pleasure programmatically)?


Solution

  • You can change any OSGi configuration programatically via the ConfigurationAdmin service described at http://www.osgi.org/javadoc/r4v42/org/osgi/service/cm/ConfigurationAdmin.html

    You'll need the PID of the configuration that you want to change (the OSGi admin console or shell will provide that). Use ConfigurationAdmin.getConfiguration(..) to retrieve the corresponding Configuration object, and call Configuration.update(...) with the changed properties.

    That being said, raising the events blacklisting timeout is usually a bad idea - event handlers that take a long time to run will block things. Use separate threads or jobs (as suggested by Chris Leggett) to do the slow work.