org.apache.stanbol.enhancer.servicesapi
Interface EnhancementEngineManager

All Known Implementing Classes:
EnginesTracker

public interface EnhancementEngineManager

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


Method Summary
 java.util.Set<java.lang.String> getActiveEngineNames()
          Getter for all active and tracked engine names.
 EnhancementEngine getEngine(org.osgi.framework.ServiceReference engineReference)
          Getter for the EnhancementEngine service for the parsed service Reference.
 EnhancementEngine getEngine(java.lang.String name)
          Getter for the EnhancementEngine for the parsed name
 org.osgi.framework.ServiceReference getReference(java.lang.String name)
          Getter for the ServiceReference of the EnhancementEngine for the parsed name
 java.util.List<org.osgi.framework.ServiceReference> getReferences(java.lang.String name)
          Getter for all ServiceReferences of the EnhancementEngines registered for the parsed name.
 boolean isEngine(java.lang.String name)
          Checks if an EnhancementEngine with the parsed name is active
 

Method Detail

getReference

org.osgi.framework.ServiceReference getReference(java.lang.String name)
Getter for the ServiceReference of the EnhancementEngine 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 Engine 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 EnhancementEngines 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 engine 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.

getEngine

EnhancementEngine getEngine(java.lang.String name)
Getter for the EnhancementEngine for the parsed name

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

isEngine

boolean isEngine(java.lang.String name)
Checks if an EnhancementEngine with the parsed name is active

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

getActiveEngineNames

java.util.Set<java.lang.String> getActiveEngineNames()
Getter for all active and tracked engine names. This is a snapshot and this set will change if EnhancementEngines become active/inactive.

Users of this method should keep in mind to check if the ServiceReferences and/or EnhancementEngines 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 getEngine(String).

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

getEngine

EnhancementEngine getEngine(org.osgi.framework.ServiceReference engineReference)
Getter for the EnhancementEngine service for the parsed service Reference. This method allows to also retrieve the service for other engines than the one with the highest service ranking by using
     for(ServiceReference engineRef : tracker.getReferences("test")){
         EnhancementEngine engine = tracker.getEngine(engineRef)
         if(engine != null) { //may become inactive in the meantime
             //save the world by using this engine!
         }
     }
 

Parameters:
engineReference - the service reference for an engine tracked by this component
Returns:
the referenced EnhancementEngine or null if no longer available.


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