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 static org.slf4j.Logger
LOG
Constructor Summary
Constructors Constructor and Description PluginRepository(org.apache.hadoop.conf.Configuration conf)
Method Summary
Methods Modifier and Type Method and Description void
finalize()
static PluginRepository
get(org.apache.hadoop.conf.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
public static final org.slf4j.Logger LOG
Constructor Detail
-
PluginRepository
public PluginRepository(org.apache.hadoop.conf.Configuration conf) throws RuntimeException
- Throws:
- <code>PluginRuntimeException</code>
- <code>RuntimeException</code>
- See Also:
- [<code>Object.Object()</code>](http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#Object())
Method Detail
-
get
public static PluginRepository get(org.apache.hadoop.conf.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:
- <code>pPluginId</code> -
- Returns:
- PluginDescriptor
-
getExtensionPoint
public ExtensionPoint getExtensionPoint(String pXpId)
Returns a extension point indentified by a extension point id.
- Parameters:
- <code>pXpId</code> -
- 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:
- <code>pDescriptor</code> -
- Returns:
- Plugin
- Throws:
- <code>PluginRuntimeException</code>
-
finalize
public void finalize() throws Throwable
- Overrides:
- <code>finalize</code> in class <code>Object</code>
- Throws:
- <code>Throwable</code>
-
getCachedClass
public Class getCachedClass(PluginDescriptor pDescriptor, String className) throws ClassNotFoundException
- Throws:
- <code>ClassNotFoundException</code>
-
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:
- <code>clazz</code> - interface class implemented by required plugins
- <code>xPointId</code> - extension point id of required plugins
- <code>orderProperty</code> - 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:
- <code>args</code> - 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:
- <code>Exception</code>