Class JarResource

java.lang.Object
cloud.piranha.resource.impl.JarResource
All Implemented Interfaces:
Resource

public class JarResource extends Object implements Resource
The default JarResource.
Author:
Manfred Riem ([email protected])
  • Constructor Details

    • JarResource

      public JarResource()
      Constructor.
    • JarResource

      public JarResource(File jarFile)
      Constructor.
      Parameters:
      jarFile - the JAR file.
  • Method Details

    • getResource

      public URL getResource(String location)
      Returns the resource.
      Specified by:
      getResource in interface Resource
      Parameters:
      location - the location.
      Returns:
      the resource
    • getResourceAsStream

      public InputStream getResourceAsStream(String location)
      Get the resource as a stream.

      Note that this method will read the content of a JAR entry into a byte-array to avoid locking the JAR file.

      Specified by:
      getResourceAsStream in interface Resource
      Parameters:
      location - the resource location.
      Returns:
      the input stream, or null if not found.
      See Also:
    • getAllLocations

      public Stream<String> getAllLocations()
      Description copied from interface: Resource
      Returns all the locations for this resource.
      Specified by:
      getAllLocations in interface Resource
      Returns:
      all the locations for this resource
    • getJarFile

      public File getJarFile()
      Returns the JAR file.
      Returns:
      the JAR file
    • setJarFile

      public void setJarFile(File jarFile)
      Set the JAR file.
      Parameters:
      jarFile - the JAR file.
    • getName

      public String getName()
      Description copied from interface: Resource
      Get the name of this resource
      Specified by:
      getName in interface Resource
      Returns:
      the name
    • toString

      public String toString()
      Overrides:
      toString in class Object