Class DescriptorScanner

java.lang.Object
io.gdcc.spi.meta.descriptor.DescriptorScanner

public final class DescriptorScanner extends Object
  • Method Details

    • scanPath

      public static List<SourcedDescriptor> scanPath(Path path) throws IOException
      Scans the specified path to identify plugin descriptors. The path can either be a directory or a JAR file. The method determines the type of the path and invokes the appropriate scanning logic to extract plugin descriptors.
      Parameters:
      path - the path to be scanned; must not be null. If the path represents a directory, plugin files contained within it will be scanned. If the path represents a JAR file, its internal entries will be scanned for descriptors.
      Returns:
      a list of SourcedPluginDescriptor objects representing plugin descriptors found at the given path. The list will be empty if no descriptors are found.
      Throws:
      IllegalArgumentException - if the provided path is null or scanning fails for other reasons caused by user.
      IOException - if an I/O error occurs while accessing the specified path or its contents.
    • hasServiceProviderInterfaceRecord

      public static boolean hasServiceProviderInterfaceRecord(SourcedDescriptor descriptor) throws IOException
      Checks whether the source referenced by the given descriptor contains a Java SPI service configuration file for the descriptor's declared kind, and whether that file explicitly lists the descriptor's implementation class.

      The source location is expected to point either to a directory root or to a JAR file. In the directory case, this method looks for a regular file at META-INF/services/<kind> below that root. In the JAR case, it looks for the corresponding JAR entry.

      If the SPI record exists, its contents are interpreted using UTF-8. Blank lines, leading/trailing whitespace, and comments introduced by # are ignored in the same spirit as standard Java service configuration files.

      Parameters:
      descriptor - the descriptor whose source and implementation metadata should be checked
      Returns:
      true if a matching SPI record exists and contains the descriptor's implementation class; false if no such SPI record exists or the record does not list that implementation
      Throws:
      IllegalArgumentException - if the descriptor points to a source location that does not exist
      IOException - if an I/O error occurs while reading the directory entry or JAR entry