Hi, On Fri, Nov 18, 2011 at 1:53 PM, Rupert Westenthaler <[email protected]> wrote: > ...I will try to give a less abstract example: > > A user configures via the Apache Felix Webconsole that the > KeywordExtractionEngine should use the taxonomy "gemet". Therefore this > engine depends on the ReferencedSite with the name "gemet". If he changes the > configuration to "dbpedia", than I need to change the filter, because now the > engine depends on the ReferencedSite with the name "dbpedia"....
I would do it like that: Create a KeywordExtractionEngineManager component (not a service) that is configured with the name of the taxonomy (multiple instances if that makes sense). KeywordExtractionEngineManager watches for ReferencedSite services having the configured name, using dynamic @Reference with 0..N cardinality for example. Once a ReferencedSite becomes available (bind() method), KeywordExtractionEngineManager creates a KeywordExtractionEngine instance, registers it as a service using BundleContext.registerService(...), and keeps track of that instance. If a ReferencedSite becomes unavailable (unbind() method), the corresponding KeywordExtractionEngine service is unregistered It's a bit of manual work, but not much. There might be a more "magic" way with service or component factories but the above is simple and understandable. Just make sure you get synchronization right ;-) -Bertrand
