Interface JarExtractor

  • All Superinterfaces:
    org.revapi.configuration.Configurable

    public interface JarExtractor
    extends org.revapi.configuration.Configurable
    The role of the jar extractor is to find class files in an archive that should be considered for API analysis.

    This is mainly meant for extracting the files from for example WAR files, etc, where the classes are nested within a more complex directory structure.

    This interface is a normal Revapi extension that further extends revapi-java. As such it is also configurable. The configuration can be placed under revapi.java.extract root using the extension id of the implementation. E.g. in XML:

     
     <revapi.java>
         <extract>
             <my.extractor.extension.id>
                 ... config is here ...
             </my.extractor.extension.id>
         </extract>
     </revapi.java>
     
     
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Optional<InputStream> extract​(org.revapi.Archive archive)
      Tries to transform the data of the archive such that it looks like a simple jar file to the analyzer.
      • Methods inherited from interface org.revapi.configuration.Configurable

        getExtensionId, getJSONSchema, initialize
    • Method Detail

      • extract

        Optional<InputStream> extract​(org.revapi.Archive archive)
        Tries to transform the data of the archive such that it looks like a simple jar file to the analyzer. This method can be difficult to implement because needs to inspect the contents of the provided input stream and "rewrap" it in a different way if needed.

        This method can theoretically base the transformation decisions on other metadata present on the provided archive instance, but that is considered dangerous because it limits the reusability of the transformer between different invocation types of Revapi (CLI vs Maven, etc, which may or may not use the same implementation of the archive).

        If the transformation is not possible the corresponding archive is supplied to the analysis in full.

        Note that the returned stream, if any, MUST be independent of the provided archiveData. This method need not close the archive.

        Parameters:
        archive - the archive to analyze
        Returns:
        an optional transformation of the input stream of the archive Oas if it were a normal JAR file or an empty optional if such transformation is not possible.