org.apache.nutch.plugin

## Class PluginRepository

- java.lang.Object
- - org.apache.nutch.plugin.PluginRepository

-     public class PluginRepository
      extends Object

  The plugin repositority is a registry of all plugins. At system boot up a repositority is builded by parsing the mainifest files of all plugins. Plugins that require not existing other plugins are not registed. For each plugin a plugin descriptor instance will be created. The descriptor represents all meta information about a plugin. So a plugin instance will be created later when it is required, this allow lazy plugin loading.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static org.slf4j.Logger` | `LOG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PluginRepository(Configuration conf)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `finalize()`
    `static PluginRepository` | `get(Configuration conf)`
    `Class` | `getCachedClass(PluginDescriptor pDescriptor, String className)`
    `ExtensionPoint` | `getExtensionPoint(String pXpId)` Returns a extension point indentified by a extension point id.
    `Object[]` | `getOrderedPlugins(Class<?> clazz, String xPointId, String orderProperty)` Get ordered list of plugins.
    `PluginDescriptor` | `getPluginDescriptor(String pPluginId)` Returns the descriptor of one plugin identified by a plugin id.
    `PluginDescriptor[]` | `getPluginDescriptors()` Returns all registed plugin descriptors.
    `Plugin` | `getPluginInstance(PluginDescriptor pDescriptor)` Returns a instance of a plugin.
    `static void` | `main(String[] args)` Loads all necessary dependencies for a selected plugin, and then runs one of the classes' main() method.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### LOG

          protected static final org.slf4j.Logger LOG

  - ### Constructor Detail

    - #### PluginRepository

          public PluginRepository(Configuration conf)
                           throws RuntimeException

      Throws:
        `RuntimeException`
      See Also:
        `Object.Object()`

  - ### Method Detail

    - #### get

          public static PluginRepository get(Configuration conf)

      Returns:
        a cached instance of the plugin repository

    - #### getPluginDescriptors

          public PluginDescriptor[] getPluginDescriptors()

      Returns all registed plugin descriptors.
      Returns:
        PluginDescriptor[]

    - #### getPluginDescriptor

          public PluginDescriptor getPluginDescriptor(String pPluginId)

      Returns the descriptor of one plugin identified by a plugin id.
      Parameters:
        `pPluginId` -
      Returns:
        PluginDescriptor

    - #### getExtensionPoint

          public ExtensionPoint getExtensionPoint(String pXpId)

      Returns a extension point indentified by a extension point id.
      Parameters:
        `pXpId` -
      Returns:
        a extentsion point

    - #### getPluginInstance

          public Plugin getPluginInstance(PluginDescriptor pDescriptor)
                                   throws PluginRuntimeException

      Returns a instance of a plugin. Plugin instances are cached. So a plugin exist only as one instance. This allow a central management of plugin own resources. After creating the plugin instance the startUp() method is invoked. The plugin use a own classloader that is used as well by all instance of extensions of the same plugin. This class loader use all exported libraries from the dependend plugins and all plugin libraries.
      Parameters:
        `pDescriptor` -
      Returns:
        Plugin
      Throws:
        `PluginRuntimeException`

    - #### finalize

          public void finalize()
                        throws Throwable

      Overrides:
        `finalize` in class `Object`
      Throws:
        `Throwable`

    - #### getCachedClass

          public Class getCachedClass(PluginDescriptor pDescriptor,
                                      String className)
                               throws ClassNotFoundException

      Throws:
        `ClassNotFoundException`

    - #### getOrderedPlugins

          public Object[] getOrderedPlugins(Class<?> clazz,
                                            String xPointId,
                                            String orderProperty)

      Get ordered list of plugins. Filter and normalization plugins are applied in a configurable "pipeline" order, e.g., if one plugin depends on the output of another plugin. This method loads the plugins in the order defined by orderProperty. If orderProperty is empty or unset, all active plugins of the given interface and extension point are loaded.
      Parameters:
        `clazz` - interface class implemented by required plugins
        `xPointId` - extension point id of required plugins
        `orderProperty` - property name defining plugin order
      Returns:
        array of plugin instances

    - #### main

          public static void main(String[] args)
                           throws Exception

      Loads all necessary dependencies for a selected plugin, and then runs one of the classes' main() method.
      Parameters:
        `args` - plugin ID (needs to be activated in the configuration), and the class name. The rest of arguments is passed to the main method of the selected class.
      Throws:
        `Exception`

Copyright © 2021 The Apache Software Foundation