Class FactoryFeature<A,T>

java.lang.Object
nz.org.riskscape.engine.plugin.FactoryFeature<A,T>
All Implemented Interfaces:
PluginFeature
Direct Known Subclasses:
CliCommand, EngineCollection, ExpressionRealizerFactory, PipelineExecutorFactory

public abstract class FactoryFeature<A,T> extends Object implements PluginFeature

Base class for features that return a new instance of something of a particular SPI, optionally accepting a contextual argument.

  • Constructor Details

    • FactoryFeature

      public FactoryFeature(Class<? extends T> implementationClass)
  • Method Details

    • lookupAll

      public static <T, F extends FactoryFeature<?, T>> List<F> lookupAll(ExtensionPoints extensionPoints, Class<F> spiFactoryClass)

      Return all FactoryFeatures by subclass registered in the extensionPoints. Use this instead of ExtensionPoints.getFeaturesOfType(Class).

    • lookup

      public static <T, F extends FactoryFeature<?, T>> F lookup(Engine engine, Class<F> spiFactoryClass)

      Return a FactoryFeature by subclass, throwing an exception if none (not even a default) is registered.

      Uses the engine's plugins and settings to lookup settings to see if a default implementation has been replaced.

    • getSpiClass

      public static <T, F extends FactoryFeature<?, T>> Class<T> getSpiClass(Class<F> spiFactoryClass)
    • getId

      public String getId()
      Returns:
      an id for this feature (based on the class name)
    • getSpiClass

      public Class<T> getSpiClass()
      Returns:
      the service provider interface class, e.g. ExpressionRealizer
    • getContextClass

      public Class<A> getContextClass()
      Returns:
      the class required by this constructor feature's newInstance method
    • newInstance

      public T newInstance(A arg)
    • newInstance

      public T newInstance()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isDefaultImplementation

      public boolean isDefaultImplementation()
      Returns:
      true if this factory will return a default implementation of the spi class