Interface Archive

All Superinterfaces:
AutoCloseable

public interface Archive extends AutoCloseable
An archive that can be launched by the Launcher.
Since:
3.2.0
Author:
Phillip Webb
  • Field Details

  • Method Details

    • getManifest

      Manifest getManifest() throws IOException
      Returns the manifest of the archive.
      Returns:
      the manifest or null
      Throws:
      IOException - if the manifest cannot be read
    • getClassPathUrls

      default Set<URL> getClassPathUrls(Predicate<Archive.Entry> includeFilter) throws IOException
      Returns classpath URLs for the archive that match the specified filter.
      Parameters:
      includeFilter - filter used to determine which entries should be included.
      Returns:
      the classpath URLs
      Throws:
      IOException - on IO error
    • getClassPathUrls

      Set<URL> getClassPathUrls(Predicate<Archive.Entry> includeFilter, Predicate<Archive.Entry> directorySearchFilter) throws IOException
      Returns classpath URLs for the archive that match the specified filters.
      Parameters:
      includeFilter - filter used to determine which entries should be included
      directorySearchFilter - filter used to optimize tree walking for exploded archives by determining if a directory needs to be searched or not
      Returns:
      the classpath URLs
      Throws:
      IOException - on IO error
    • isExploded

      default boolean isExploded()
      Returns if this archive is backed by an exploded archive directory.
      Returns:
      if the archive is exploded
    • getRootDirectory

      default File getRootDirectory()
      Returns the root directory of this archive or null if the archive is not backed by a directory.
      Returns:
      the root directory
    • close

      default void close() throws Exception
      Closes the Archive, releasing any open resources.
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception - if an error occurs during close processing
    • create

      static Archive create(Class<?> target) throws Exception
      Factory method to create an appropriate Archive from the given Class target.
      Parameters:
      target - a target class that will be used to find the archive code source
      Returns:
      an new Archive instance
      Throws:
      Exception - if the archive cannot be created
    • create

      static Archive create(ProtectionDomain protectionDomain) throws Exception
      Throws:
      Exception
    • create

      static Archive create(File target) throws Exception
      Factory method to create an Archive from the given File target.
      Parameters:
      target - a target File used to create the archive. May be a directory or a jar file.
      Returns:
      a new Archive instance.
      Throws:
      Exception - if the archive cannot be created