Chain Manager

The ChainManager provides name based access to all active Enhancement Chains and their ServiceReferences. This interface is typically used by components that need to lookup Chains based on their name. However the ChainsTracker implementation can also be used to track specific Chains.

ChainManager interface

This is the Java API providing access to registered chains in the ways as described above. This interface includes the following methods:

/** Constant for the name of the DefaultChain */
/** Getter for all names with active Chains */
getActiveChainNames() : Set<String>
/** Getter for the ServiceReference to the Chain 
    with a given name sorted by service ranking */
getReference(String name) : ServiceReference
/** Getter for all ServiceReferences to Chains 
    with a given name */
getReferences(String name)
/** Getter for the Chain with a given name */
+ getChain(Stirng name) : Chain
/** Getter for all Chains with a given name sorted 
    by service ranking */
+ getChains(String name) : List<Chain>
/** Getter for a Chain based on a service reference */
+ getChain(ServiceReference ref) : Chain
/** Checks if there is a chain for the given name */
+ isChain(String name) : boolean
/** Getter for the default chain */
+ getDefault() : Chain

There are two implementations of this interface available:

ChainManager Service

This is an implementation of the ChainManager interface that is registered as OSGI service. It can be used e.g. by using the @Reference annotation

ChainManager chainManager

This service is provided by the "org.apache.stanbol.enhancer.chainmanger" module and is included in all Stanbol launchers.


This is an utility similar to the standard OSGI ServiceTracker that allows to track some/all chains. It also supports the usage of a ServiceTrackerCustomizer so that users of this utility can directly react to changes of tracked chains.

//track only "myChain" and "otherChain"
ChainsTracker tracker = new ChainsTracker(
    context, "myChain","otherChain");; //start tracking

//the tracker need to be closed if no longer needed
tracker = null;

For most users the ChainManager service is sufficient and preferable. Direct use of the ChainsTracker is only recommended if one needs only to track some specific chains and especially if one needs to get notified an changes of such chains.