Class FolderClasspathPluginSetupDescriptor

java.lang.Object
de.iip_ecosphere.platform.support.plugins.URLPluginSetupDescriptor
de.iip_ecosphere.platform.support.plugins.FolderClasspathPluginSetupDescriptor
All Implemented Interfaces:
PluginSetupDescriptor

public class FolderClasspathPluginSetupDescriptor extends URLPluginSetupDescriptor
Default plugin setup descriptor based based on loading from a project folder containing jars and the classpath in "classpath", in "target/jars/classpath", or in "target/classes/classpath".
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • FolderClasspathPluginSetupDescriptor

      public FolderClasspathPluginSetupDescriptor(File folder)
      Creates an instance based on project folder containing jars and the classpath in "target/classes/classpath".
      Parameters:
      folder - the basis folder
    • FolderClasspathPluginSetupDescriptor

      public FolderClasspathPluginSetupDescriptor(File folder, boolean descriptorOnly, File... appends)
      Creates an instance based on project folder containing jars and the classpath in "target/classes/classpath".
      Parameters:
      folder - the basis folder
      descriptorOnly - load the descriptor JARs only or the full thing
      appends - further classpath files that shall be appended, e.g., logging, may be null
  • Method Details

    • getInstallDir

      public File getInstallDir()
      Description copied from interface: PluginSetupDescriptor
      Returns the installation directory.
      Returns:
      the installation directory, may be null
    • findClasspathFile

      public static File findClasspathFile(File folder, String suffix)
      Finds the classpath file.
      Parameters:
      folder - the folder to start searching
      suffix - optional suffix, e.g., "-win", may be empty or null for none
      Returns:
      the classpath file
    • adjustBase

      public static File adjustBase(File folder)
      Adjusts the base directory.
      Parameters:
      folder - the folder to be used as base directory
      Returns:
      the adjusted base directory
    • loadClasspathSafe

      public static URL[] loadClasspathSafe(File folder, boolean descriptorOnly, File... appends)
      Loads a resource in classpath format and returns the specified classpath entries as URLs. Logs errors and exceptions.
      Parameters:
      folder - the basis folder
      descriptorOnly - only the first/two entries, the full thing else
      appends - further classpath files that shall be appended, e.g., logging, may be null
      Returns:
      the URLs, may be empty
      See Also:
    • loadClasspathFileSafe

      public static URL[] loadClasspathFileSafe(File cpFile, boolean descriptorOnly)
      Loads a classpath file relative to the actual jars and returns the specified classpath entries as URLs. Logs errors and exceptions.
      Parameters:
      cpFile - the classpath file
      descriptorOnly - only the first/two entries, the full thing else
      Returns:
      the URLs, may be empty
    • loadClasspathFileSafe

      private static URL[] loadClasspathFileSafe(File cpFile, File base, boolean descriptorOnly, File... appends)
      Loads a classpath file relative to the actual jars and returns the specified classpath entries as URLs. Logs errors and exceptions.
      Parameters:
      cpFile - the classpath file
      base - the base folder use to make relative classpath entries absolute
      descriptorOnly - only the first/two entries, the full thing else
      appends - further classpath files that shall be appended, e.g., logging, may be null
      Returns:
      the URLs, may be empty
    • readClasspathFile

      public static FolderClasspathPluginSetupDescriptor.ClasspathFile readClasspathFile(InputStream in, File base) throws IOException
      Reads and parses a given classpath file.
      Parameters:
      in - the input stream
      base - the base folder use to make relative classpath entries absolute
      Returns:
      the classpath file description object
      Throws:
      IOException - if accessing the classpath file fails
    • stripExtension

      private static final String stripExtension(String name)
      Strip the extension of a file name.
      Parameters:
      name - the name
      Returns:
      the stripped name
    • createClassLoader

      protected ClassLoader createClassLoader(URL[] urls, ClassLoader parent)
      Description copied from class: URLPluginSetupDescriptor
      Actually creates the classloader.
      Overrides:
      createClassLoader in class URLPluginSetupDescriptor
      Parameters:
      urls - the URLs to create the classloader from
      parent - the parent class loader
      Returns:
      the created classloader
    • getPluginDescriptors

      public Stream<PluginDescriptor> getPluginDescriptors(ClassLoader loader)
      Description copied from interface: PluginSetupDescriptor
      Returns the plugin descriptors represented by this setup descriptor.
      Parameters:
      loader - the class loader to use, preferably the result of PluginSetupDescriptor.createClassLoader(ClassLoader)
      Returns:
      the plugin descriptors
    • getPluginDescriptors

      public static Stream<PluginDescriptor> getPluginDescriptors(URL[] urls, ClassLoader loader)
      Returns the plugin descriptors represented by this setup descriptor. We just look into the first (main) or second (optional test) jar to speed up and focus the search for descriptors.
      Parameters:
      urls - the classpath URLs
      loader - the class loader to use, preferably the result of URLPluginSetupDescriptor.createClassLoader(ClassLoader)
      Returns:
      the plugin descriptors
      See Also:
    • loadDescriptors

      private static void loadDescriptors(URL url, ClassLoader loader, List<PluginDescriptor> result)
      Loads the plugin descriptors from url.
      Parameters:
      url - the URL to load the descriptors from
      loader - the class loader to use, preferably the result of URLPluginSetupDescriptor.createClassLoader(ClassLoader)
      result - modified with added plugin descriptor instances as side effect
    • getLogger

      private static Logger getLogger()
      Returns the logger for this class.
      Returns:
      the logger