Class InputJarArchive

  • All Implemented Interfaces:
    Archive, ReadableArchive

    @Service(name="jar")
    @PerLookup
    public class InputJarArchive
    extends JarArchive
    implements ReadableArchive
    This implementation of the Archive deal with reading jar files either from a JarFile or from a JarInputStream
    Author:
    Jerome Dochez
    • Field Detail

      • deplLogger

        public static final Logger deplLogger
      • jarFile

        protected volatile JarFile jarFile
    • Constructor Detail

      • InputJarArchive

        public InputJarArchive()
    • Method Detail

      • addEntry

        public OutputStream addEntry​(String name)
                              throws IOException
        Parameters:
        name - the entry name
        Returns:
        an @see java.io.OutputStream for a new entry in this current abstract archive.
        Throws:
        IOException
      • getDirectories

        public Collection<String> getDirectories()
                                          throws IOException
        Returns the collection of first level directories in this archive.

        Avoid having to fetch all the entries if we can avoid it. The only time we must do that is if size() is invoked on the collection. Use the CollectionWrappedEnumeration for this optimization which will create a full in-memory list of the entries only if and when needed to satisfy the size() method.

        Specified by:
        getDirectories in interface Archive
        Returns:
        collection of directories under the root of this archive
        Throws:
        IOException
      • create

        public void create​(URI uri)
                    throws IOException
        creates a new abstract archive with the given path
        Parameters:
        uri - the path to create the archive
        Throws:
        IOException
      • entries

        public Enumeration<String> entries()
        Description copied from interface: Archive
        Returns an enumeration of the module file entries. All elements in the enumeration are of type String. Each String represents a file name relative to the root of the module.
        Specified by:
        entries in interface Archive
        Returns:
        an enumeration of the archive file entries.
      • entries

        public Enumeration entries​(Enumeration embeddedArchives)
        Returns:
        an @see java.util.Enumeration of entries in this abstract archive, providing the list of embedded archive to not count their entries as part of this archive
      • exists

        public boolean exists​(String name)
                       throws IOException
        Returns the existence of the given entry name The file name must be relative to the root of the module.
        Specified by:
        exists in interface ReadableArchive
        Overrides:
        exists in class JarArchive
        Parameters:
        name - the file name relative to the root of the module. * @return the existence the given entry name.
        Returns:
        the existence the given entry name.
        Throws:
        IOException
      • getEntry

        public InputStream getEntry​(String entryName)
                             throws IOException
        Description copied from interface: ReadableArchive
        Returns the InputStream for the given entry name The file name must be relative to the root of the module.
        Specified by:
        getEntry in interface ReadableArchive
        Parameters:
        entryName - entry name
        Returns:
        a @see java.io.InputStream for an existing entry in the current abstract archive
        Throws:
        IOException
      • getEntrySize

        public long getEntrySize​(String name)
        Returns the entry size for a given entry name or 0 if not known
        Specified by:
        getEntrySize in interface ReadableArchive
        Parameters:
        name - the entry name
        Returns:
        the entry size
      • getManifest

        public Manifest getManifest()
                             throws IOException
        Description copied from interface: Archive
        Returns the manifest information for this archive
        Specified by:
        getManifest in interface Archive
        Returns:
        the manifest information for this abstract archive
        Throws:
        IOException
      • getURI

        public URI getURI()
        Returns the path used to create or open the underlying archive
        Specified by:
        getURI in interface Archive
        Returns:
        the path for this archive.
      • exists

        public boolean exists()
        Specified by:
        exists in interface ReadableArchive
        Returns:
        true if this abstract archive maps to an existing jar file
      • delete

        public boolean delete()
        deletes the underlying jar file
        Specified by:
        delete in interface ReadableArchive
      • renameTo

        public boolean renameTo​(String name)
        rename the underlying jar file
        Specified by:
        renameTo in interface ReadableArchive
        Parameters:
        name - the archive name
      • getSubArchive

        public ReadableArchive getSubArchive​(String name)
                                      throws IOException
        Description copied from interface: ReadableArchive
        Returns an instance of this archive abstraction for an embedded archive within this archive.
        Specified by:
        getSubArchive in interface ReadableArchive
        Parameters:
        name - is the entry name relative to the root for the archive
        Returns:
        an Archive for an embedded archive indentified with the name parameter
        Throws:
        IOException