Class Any23PluginManager


  • public class Any23PluginManager
    extends Object
    The Any23PluginManager is responsible for inspecting dynamically the classpath and retrieving useful classes.
    Author:
    Michele Mostarda (mostarda@fbk.eu)
    • Field Detail

      • CLI_PACKAGE

        public static final String CLI_PACKAGE
        Any23 Command Line Interface package.
      • PLUGIN_DIRS_PROPERTY

        public static final String PLUGIN_DIRS_PROPERTY
        Property where look for plugins.
        See Also:
        Constant Field Values
      • PLUGIN_DIRS_LIST_SEPARATOR

        public static final String PLUGIN_DIRS_LIST_SEPARATOR
        List separator for the string declaring the plugin list.
        See Also:
        Constant Field Values
    • Method Detail

      • loadJAR

        public boolean loadJAR​(File jar)
        Loads a JAR file in the classpath.
        Parameters:
        jar - the JAR file to be loaded.
        Returns:
        true if the JAR is added for the first time to the classpath, false otherwise.
      • loadJARs

        public Throwable[] loadJARs​(File... jars)
        Loads a list of JARs in the classpath.
        Parameters:
        jars - list of JARs to be loaded.
        Returns:
        list of exceptions raised during the loading.
      • loadClassDir

        public boolean loadClassDir​(File classDir)
        Loads a classes directory in the classpath.
        Parameters:
        classDir - the directory to be loaded.
        Returns:
        true if the directory is added for the first time to the classpath, false otherwise.
      • loadClassDirs

        public Throwable[] loadClassDirs​(File... classDirs)
        Loads a list of class dirs in the classpath.
        Parameters:
        classDirs - list of class dirs to be loaded.
        Returns:
        list of exceptions raised during the loading.
      • loadJARDir

        public boolean loadJARDir​(File jarDir)
        Loads all the JARs detected in a given directory.
        Parameters:
        jarDir - directory containing the JARs to be loaded. Example '/usr/local/apache-tomcat-7.0.72/webapps/apache-any23-service-2.2-SNAPSHOT/WEB-INF/lib/apache-any23-openie'
        Returns:
        true if all JARs in dir are loaded.
      • loadFiles

        public Throwable[] loadFiles​(File... files)
        Loads a generic list of files, trying to determine the type of every file.
        Parameters:
        files - list of files to be loaded.
        Returns:
        list of errors occurred during loading.
      • getPlugins

        public <T> Iterator<T> getPlugins​(Class<T> type)
                                   throws IOException
        Returns all classes within the specified packageName satisfying the given class filter. The search is performed on the static classpath (the one the application started with) and the dynamic classpath (the one specified using the load methods).
        Type Parameters:
        T - type of filtered class.
        Parameters:
        type - of filtered class.
        Returns:
        list of matching classes.
        Throws:
        IOException - if there is an error obtaining plugins.
      • getTools

        public Iterator<Tool> getTools()
                                throws IOException
        Returns the list of all the Tool classes declared within the classpath.
        Returns:
        not null list of tool classes.
        Throws:
        IOException - if there is an error obtaining Tool's from the classpath.
      • loadPlugins

        public String loadPlugins​(File... pluginLocations)
        Loads plugins from a list of specified locations.
        Parameters:
        pluginLocations - list of locations.
        Returns:
        a report about the loaded plugins.
      • getApplicableTools

        public Iterator<Tool> getApplicableTools​(File... pluginLocations)
                                          throws IOException
        Returns an Iterator of tools that have been detected within the given list of locations.
        Parameters:
        pluginLocations - list of plugin locations.
        Returns:
        set of detected tools.
        Throws:
        IOException - if there is an error acessing Tool's.