net.sf.okapi.common.plugins

## Class PluginsManager

- java.lang.Object
- - net.sf.okapi.common.plugins.PluginsManager

-     public class PluginsManager
      extends java.lang.Object

  Provides a way to discover and list plug-ins for a given location or file.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PluginsManager()` Create a PluginsManager that uses the current thread's context ClassLoader when loading plugins.
    `PluginsManager(java.lang.ClassLoader parentClassLoader)` Create a PluginsManager that uses the specified ClassLoader when loading plugins.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `cleanupJarFileFactory(java.lang.String... jarNames)` cleanup jar file factory cache http://loracular.blogspot.com/2009/12/dynamic-class-loader-with.html
    `static void` | `closeOpenJars(java.lang.ClassLoader classLoader)` Workaround for non-released jar file lock by URLClassLoader http://loracular.blogspot.com/2009/12/dynamic-class-loader-with.html
    `void` | `discover(java.io.File pluginsDir, boolean append)` Explores the given file or directory for plug-ins and add them to this manager.
    `java.net.URLClassLoader` | `getClassLoader()` Gets the URLClassLoader to use for creating new instance of the components listed in this manager.
    `java.util.List<PluginItem>` | `getList()` Gets the list of all the plug-ins currently in this manager.
    `java.util.List<java.lang.String>` | `getList(int type)` Gets the list of the class names of all available plug-ins of a given type currently available in this manager.
    `java.io.File` | `getPluginsDir()` Gets the directory where the plug-ins are located.
    `java.util.ArrayList<java.net.URL>` | `getURLs()` Gets the list of URLs of the jars containing plug-ins currently in this manager.
    `void` | `releaseClassLoader()`

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

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

- - ### Constructor Detail

    - #### PluginsManager

          public PluginsManager()

      Create a PluginsManager that uses the current thread's context ClassLoader when loading plugins.

    - #### PluginsManager

          public PluginsManager(java.lang.ClassLoader parentClassLoader)

      Create a PluginsManager that uses the specified ClassLoader when loading plugins.
      Parameters:
        `parentClassLoader` - ClassLoader to be used as the parent of any ClassLoaders used to load plugins.

  - ### Method Detail

    - #### discover

          public void discover(java.io.File pluginsDir,
                      boolean append)

      Explores the given file or directory for plug-ins and add them to this manager.
      Parameters:
        `pluginsDir` - the directory where the plugins are located.
        `append` - true to preserve any plug-ins already existing in this manager, false to reset and start with no plug-in.

    - #### getList

          public java.util.List<java.lang.String> getList(int type)

      Gets the list of the class names of all available plug-ins of a given type currently available in this manager. The method `discover(File, boolean)` must be called once before calling this method.
      Parameters:
        `type` - the type of plug-ins to list.
      Returns:
        the list of available plug-ins for the given type.

    - #### getList

          public java.util.List<PluginItem> getList()

      Gets the list of all the plug-ins currently in this manager.
      Returns:
        the list of all the plug-ins currently in this manager.

    - #### getURLs

          public java.util.ArrayList<java.net.URL> getURLs()

      Gets the list of URLs of the jars containing plug-ins currently in this manager.
      Returns:
        the list of URLs.

    - #### getClassLoader

          public java.net.URLClassLoader getClassLoader()

      Gets the URLClassLoader to use for creating new instance of the components listed in this manager. The method `discover(File, boolean)` must be called once before calling this method.
      Returns:
        the URLClassLoader for this manager.

    - #### getPluginsDir

          public java.io.File getPluginsDir()

      Gets the directory where the plug-ins are located.
      Returns:
        directory path.

    - #### releaseClassLoader

          public void releaseClassLoader()

    - #### closeOpenJars

          public static void closeOpenJars(java.lang.ClassLoader classLoader)

      Workaround for non-released jar file lock by URLClassLoader http://loracular.blogspot.com/2009/12/dynamic-class-loader-with.html

    - #### cleanupJarFileFactory

          public static boolean cleanupJarFileFactory(java.lang.String... jarNames)

      cleanup jar file factory cache http://loracular.blogspot.com/2009/12/dynamic-class-loader-with.html