Enhancement Engine Manager
The EnhancementEngineManager provides name based access to all active EnhancementEngines and their ServiceReferences. This interface is typically used by components that need to lookup EnhancementEngines based on their name. However the EngineTracker implementation can also be used to track specific EnhancementEngines.
EnhancementEngineManager interface
This is the Java API providing access to registered EnhancementEngines in the ways as described above. This interface includes the following methods:
/** Getter for all names with active engines */ getActiveEngineNames() : Set<String> /** Getter for the ServiceReference to the engine with a given name */ getReference(String name) : ServiceReference /** Getter for all ServiceReferences to engines with a given name sorted by service ranking */ getReferences(String name) /** Getter for the engine with a given name */ + getEngine(Stirng name) : EnhancementEngine /** Getter for all engines with a given name sorted by service ranking */ + getEngines(String name) : List<EnhancementEngine> /** Getter for an engine based on a service reference */ + getEngine(ServiceReference ref) : EnhancementEgnie /** Checks if there is an engine for the given name */ + isEngine(String name) : boolean
There are two implementations of this interface available:
EnhancementEngineManager Service
This is an implementation of the EnhancementEngineManager interface that is registered as OSGI service. It can be used e.g. by using the @Reference annotation
@Reference EnhancementEngineManager engineManager
This service is provided by the "org.apache.stanbol.enhancer.enginemanager" module and is included in all Stanbol launchers.
EnginesTracker
This is an utility similar to the standard OSGI ServiceTracker which allows to track some/all EnhancementEngines. It also supports the usage of a ServiceTrackerCustomizer so that users of that utility can directly react to changes of tracked EnhancementEngines.
//track only "myEngine" and "otherEngine" EnginesTracker tracker = new EnginesTracker( context, "myEngine","otherEngine"); tracker.open(); //start tracking //the tracker need to be closed if no longer needed tracker.close() tracker = null;
For most users the EnhancementEngineManager service is sufficient and preferable. Direct use of the EngineTracker is only recommended if one needs only to track some specific engines and especially if one needs to get notified an changes of such engines.
The implementation of the WeightedChain
is a good example for the intended usage of the EnginesTracker.