Class JarZipSchemeResourceFinderFactory

java.lang.Object
org.glassfish.jersey.server.internal.scanning.JarZipSchemeResourceFinderFactory
All Implemented Interfaces:
UriSchemeResourceFinderFactory

final class JarZipSchemeResourceFinderFactory extends Object implements UriSchemeResourceFinderFactory
A "jar", "zip" and "wsjar" scheme URI scanner that recursively jar files. Jar entries are reported to a ResourceProcessor.
  • Field Details

    • SCHEMES

      private static final Set<String> SCHEMES
  • Constructor Details

    • JarZipSchemeResourceFinderFactory

      JarZipSchemeResourceFinderFactory()
      Create new "jar", "zip" and "wsjar" scheme URI scanner factory.
  • Method Details

    • getSchemes

      public Set<String> getSchemes()
      Description copied from interface: UriSchemeResourceFinderFactory
      Get the set of supported URI schemes.
      Specified by:
      getSchemes in interface UriSchemeResourceFinderFactory
      Returns:
      the supported URI schemes.
    • create

      public JarZipSchemeResourceFinderFactory.JarZipSchemeScanner create(URI uri, boolean recursive)
      Description copied from interface: UriSchemeResourceFinderFactory
      Create new ResourceFinder for a given resource URI.
      Specified by:
      create in interface UriSchemeResourceFinderFactory
      Parameters:
      uri - resource URI.
      recursive - defines whether a resource finder should recursively scan any recognized sub-resource URIs (value of true) or not (value of false).
      Returns:
      resource finder for a given URI.
    • getInputStream

      private InputStream getInputStream(String jarUrlString) throws IOException
      Obtain a InputStream of the jar file.

      For most platforms the format for the zip or jar follows the form of the <a href="http://docs.sun.com/source/819-0913/author/jar.html#jarprotocol"jar protcol.

      • jar:file:///tmp/fishfingers.zip!/example.txt
      • zip:http://www.example.com/fishfingers.zip!/example.txt

      On versions of the WebLogic application server a proprietary format is supported of the following form, which assumes a zip file located on the local file system:

      • zip:/tmp/fishfingers.zip!/example.txt
      • zip:d:/tempfishfingers.zip!/example.txt

      This method will first attempt to create a InputStream as follows:

         new URL(jarUrlString).openStream();
       
      if that fails with a MalformedURLException then the method will attempt to create a InputStream instance as follows:
        return new new FileInputStream(
            UriComponent.decode(jarUrlString, UriComponent.Type.PATH)));
       
      Parameters:
      jarUrlString - the raw scheme specific part of a URI minus the jar entry
      Returns:
      a InputStream.
      Throws:
      IOException - if there is an error opening the stream.