org.apache.stanbol.enhancer.servicesapi.helper
Class AbstractEnhancementEngine<A extends java.lang.Exception,D extends java.lang.Exception>

java.lang.Object
  extended by org.apache.stanbol.enhancer.servicesapi.helper.AbstractEnhancementEngine<A,D>
Type Parameters:
A - Exception thrown by the activate(ComponentContext) method
D - Exception thrown by the deactivate(ComponentContext) method
All Implemented Interfaces:
EnhancementEngine

@Properties(value={@Property(name="stanbol.enhancer.engine.name"),@Property(name="service.ranking")})
@Service
public abstract class AbstractEnhancementEngine<A extends java.lang.Exception,D extends java.lang.Exception>
extends java.lang.Object
implements EnhancementEngine

Abstract base implementation that reads the of the EnhancementEngine.PROPERTY_NAME from configuration parsed in the activate methods and implements the getName() method. If the name is missing or empty a ConfigurationException is thrown.

In addition this Class defines a Service, Component and Property annotations for

This annotations can be Component.inherit() to sub classes and would allow users to specify the name and the ranking of an engine by using e.g. the Apache Felix Webconsole.

Author:
Rupert Westenthaler

Field Summary
 
Fields inherited from interface org.apache.stanbol.enhancer.servicesapi.EnhancementEngine
CANNOT_ENHANCE, ENHANCE_ASYNC, ENHANCE_SYNCHRONOUS, PROPERTY_NAME
 
Constructor Summary
AbstractEnhancementEngine()
           
 
Method Summary
protected  void activate(org.osgi.service.component.ComponentContext ctx)
          activator that reads and validates the EnhancementEngine.PROPERTY_NAME property from the ComponentContext.getProperties().
protected  void deactivate(org.osgi.service.component.ComponentContext ctx)
          Deactivates this component and re-sets the name to null
 java.lang.String getName()
          Getter for the name of this EnhancementEngine instance as configured by EnhancementEngine.PROPERTY_NAME
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.stanbol.enhancer.servicesapi.EnhancementEngine
canEnhance, computeEnhancements
 

Constructor Detail

AbstractEnhancementEngine

public AbstractEnhancementEngine()
Method Detail

activate

@Activate
protected void activate(org.osgi.service.component.ComponentContext ctx)
                 throws org.osgi.service.cm.ConfigurationException,
                        A extends java.lang.Exception
activator that reads and validates the EnhancementEngine.PROPERTY_NAME property from the ComponentContext.getProperties().

Parameters:
ctx - the component context
Throws:
org.osgi.service.cm.ConfigurationException - if the required property EnhancementEngine.PROPERTY_NAME is missing or empty
A - to allow sub classes to throw any kind of exception
A extends java.lang.Exception

deactivate

@Deactivate
protected void deactivate(org.osgi.service.component.ComponentContext ctx)
                   throws D extends java.lang.Exception
Deactivates this component and re-sets the name to null

Parameters:
ctx - not used
Throws:
D - to allow sub classes to throw any Exception
D extends java.lang.Exception

getName

public final java.lang.String getName()
Description copied from interface: EnhancementEngine
Getter for the name of this EnhancementEngine instance as configured by EnhancementEngine.PROPERTY_NAME

Specified by:
getName in interface EnhancementEngine
Returns:
the name


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