Class Plugin

java.lang.Object
nz.org.riskscape.engine.plugin.Plugin

public abstract class Plugin extends Object

A Riskscape Plugin. So far, a riskscape plugin is used to help initialize an engine, the expectation being that the plugin can supply an engine with types, functions and models etc.

Derived from the Nutch project's plugin system

  • Constructor Details

  • Method Details

    • getId

      public String getId()
    • startUp

      protected void startUp(Map<String,List<String>> settings) throws PluginRuntimeException

      Will be invoked on plugin start up and before initializeEngine(Engine, ProblemSink) is called. Gives plugins a change to bootstrap some expensive global state.

      Throws:
      PluginRuntimeException
    • startUp

      public void startUp(Map<String,List<String>> settings, ProblemSink terminal)
    • shutDown

      public void shutDown() throws PluginRuntimeException

      Shutdown the plugin. Might be called when the engine is destroyed.

      Throws:
      PluginRuntimeException
    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • initializeEngine

      public abstract List<Problem> initializeEngine(Engine engine)

      Initialize the Engine with any services that are provided by this Plugin. For example: - Models - BookmarkResolvers - ResourceLoaders

      Parameters:
      engine - the engine to populate with things.
      Returns:
      any non-fatal warnings or errors generated that can be shown to the user
    • initializeEngine

      public void initializeEngine(Engine engine, ProblemSink problemSink)

      Initialize the Engine with any services that are provided by this Plugin. For example: - Models - BookmarkResolvers - ResourceLoaders

      Use this method over initializeEngine(Engine) to report problems immediately, which can be a better way to give feedback for the user, especially where things can happen over a greater period of time.

      Parameters:
      engine - the engine to populate with things.
      problemSink - a place to report any non-fatal warnings or errors generated that can be shown to the user
    • initializeProject

      public List<Problem> initializeProject(Project project, Engine engine)

      Fill a Project with goodies, usually by scanning through the Project's Config. For example: - Types - IdentifiedFunctions - etc

      Parameters:
      project - the project to populate
      engine - containing services that may be required.
      Returns:
      any non-fatal warnings or errors generated that can be shown to the user
    • supportsFeature

      @Deprecated public <T> Optional<T> supportsFeature(Class<T> spi)
      Deprecated.
      use the new ExtensionPoint API instead. We should start moving Features across to that as and when we touch them.

      Query a Plugin to see if it supports the given 'service provider interface'. Support is currently limited to interfaces defined by the core engine classes - there is no support for plugins defining their own (yet) as this requires some class loader magic that we don't yet need.

      The current implementation, which isn't likely to last, queries the Plugin object itself to see if it implements the given interface.

      The plan for the future might be to move things like resolvers and models etc in to SPI specific things to more precisely control the way the engine is built/augmented

      Parameters:
      spi - the interface to look for in this plugin
      Returns:
      an object implementing the spi if it is supported, or Optional.empty() if this spi is not supported by the Plugin.
    • getI18nClassLoader

      public ClassLoader getI18nClassLoader()
      Returns:
      the classloader this plugin provides for loading i18n resources. This method should be used in preference to the descriptor's default implementation in case the plugin wants to customize the class loader in someway.
    • getExtensionPoints

      public List<Class<? extends PluginFeature>> getExtensionPoints()

      Returns a list of PluginFeature classes advertised by this Plugin as possible extension points. While most extension points will be implemented in the core of the engine, it is possible for plugins to advertise their own for other dependent plugins to implement.

    • getFeatures

      public List<PluginFeature> getFeatures()
      Returns:
      a list of PluginFeatures implemented by this Plugin
    • getDescriptor

      public PluginDescriptor getDescriptor()