org.apache.stanbol.enhancer.servicesapi
Interface ChainManager

All Known Implementing Classes:
ChainsTracker

public interface ChainManager

Interface that allows to lookup ServiceReference and Chain services based on the name.


Field Summary
static java.lang.String DEFAULT_CHAIN_NAME
          The name of the default fault Chain as used by the algorithm to determine the Chain returned by getDefault().
 
Method Summary
 java.util.Set<java.lang.String> getActiveChainNames()
          Getter for the names of all currently active enhancement chains.
 Chain getChain(org.osgi.framework.ServiceReference chainReference)
          Getter for the Chain service for the parsed service Reference.
 Chain getChain(java.lang.String name)
          Getter for the Chain with the highest Constants.SERVICE_RANKING registered for the parsed name.
 Chain getDefault()
          Getter for the default Chain.
 org.osgi.framework.ServiceReference getReference(java.lang.String name)
          Getter for the ServiceReference of the Chain for the parsed name
 java.util.List<org.osgi.framework.ServiceReference> getReferences(java.lang.String name)
          Getter for all ServiceReferences of the Chains registered for the parsed name.
 boolean isChain(java.lang.String name)
          Checks if at least a single Chain with the parsed name is currently registered as OSGI service.
 

Field Detail

DEFAULT_CHAIN_NAME

static final java.lang.String DEFAULT_CHAIN_NAME
The name of the default fault Chain as used by the algorithm to determine the Chain returned by getDefault().

See the specification of enhancement chains for details.

See Also:
Constant Field Values
Method Detail

getActiveChainNames

java.util.Set<java.lang.String> getActiveChainNames()
Getter for the names of all currently active enhancement chains. This is a snapshot and this set will change if Chains become active/inactive.

Users of this method should keep in mind to check if the ServiceReferences and/or Chains retrieved by the names in the returned set may no longer be available. Therefore it is strongly recommended to checks for null values on results of subsequent calls to getReference(String) or getChain(String).

Returns:
the set with all names of currently active chains.

getReference

org.osgi.framework.ServiceReference getReference(java.lang.String name)
Getter for the ServiceReference of the Chain for the parsed name

Parameters:
name - The name - MUST NOT be null empty and tracked by this tracker
Returns:
the ServiceReference or null if no Chain with the given name is active
Throws:
java.lang.IllegalArgumentException - if the parsed name is null, empty or not tracked by this tracker instance.

getReferences

java.util.List<org.osgi.framework.ServiceReference> getReferences(java.lang.String name)
                                                                  throws java.lang.IllegalArgumentException
Getter for all ServiceReferences of the Chains registered for the parsed name. The list of references is sorted by Constants.SERVICE_RANKING.

Parameters:
name - The name - MUST NOT be null empty and tracked by this tracker
Returns:
the list of ServiceReferences sorted by Constants.SERVICE_RANKING with the highest ranking in the first position. If no chain for the parsed name is active an empty list is returned. with the given name is active
Throws:
java.lang.IllegalArgumentException - if the parsed name is null, empty or not tracked by this tracker instance.

getChain

Chain getChain(java.lang.String name)
Getter for the Chain with the highest Constants.SERVICE_RANKING registered for the parsed name.

Parameters:
name - the name of the Chain
Returns:
the Chain or null if no Chain with this name is registered as OSGI service.
Throws:
java.lang.IllegalArgumentException - if null or an empty String is parsed as name.

getChain

Chain getChain(org.osgi.framework.ServiceReference chainReference)
Getter for the Chain service for the parsed service Reference. This method allows to also retrieve the service for other chains than the one with the highest service ranking by using
     for(ServiceReference chainRef : tracker.getReferences("test")){
         Chain chain = tracker.getChain(chainRef)
         if(chain != null) { //may become inactive in the meantime
             //start the catastrophic chain of events that caused the Big Bang
         }
     }
 

Parameters:
chainReference - the service reference for a tracked chain
Returns:
the referenced Chain or null if no longer available.

isChain

boolean isChain(java.lang.String name)
Checks if at least a single Chain with the parsed name is currently registered as OSGI service.

Parameters:
name - the name
Returns:
the state
Throws:
java.lang.IllegalArgumentException - if null or an empty String is parsed as name.

getDefault

Chain getDefault()
Getter for the default Chain. This is the Chain that MUST BE used to enhance ContentItem if the no Chain was explicitly parsed in the enhancement request.

The default Chain is the Chain with the value of the property Chain.PROPERTY_NAME is equals to DEFAULT_CHAIN_NAME and the highest Constants.SERVICE_RANKING. If no Chain with the name "default" exists the Chain with the highest service ranking (regardless of its name) is considered the default Chain.

Returns:
the default Chain or null if no Chain is available


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.