Class UrlResource

java.lang.Object
org.jmxtrans.agent.util.io.AbstractResource
org.jmxtrans.agent.util.io.UrlResource
All Implemented Interfaces:
Resource

public class UrlResource
extends AbstractResource
implements Resource
Resource for http://..., https://... or file://....
Author:
Cyrille Le Clerc
  • Field Details

    • logger

      protected final Logger logger
  • Constructor Details

  • Method Details

    • getFile

      @Nonnull public File getFile()
      Description copied from interface: Resource
      Return a File handle for this resource.
      Specified by:
      getFile in interface Resource
      Overrides:
      getFile in class AbstractResource
    • exists

      public boolean exists()
      Description copied from class: AbstractResource
      This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened. This will cover both directories and content resources.
      Specified by:
      exists in interface Resource
      Overrides:
      exists in class AbstractResource
    • lastModified

      public long lastModified()
      Description copied from interface: Resource
      Determine the last-modified timestamp for this resource.
      Specified by:
      lastModified in interface Resource
      Overrides:
      lastModified in class AbstractResource
    • configureUrlConnection

      protected void configureUrlConnection​(URLConnection conn)
    • getInputStream

      @Nonnull public InputStream getInputStream()
      Description copied from interface: Resource
      Return an InputStream.

      It is expected that each call creates a fresh stream.

      Specified by:
      getInputStream in interface Resource
      Returns:
      the input stream for the underlying resource (must not be null)
    • getDescription

      public String getDescription()
      Description copied from interface: Resource
      Return a description for this resource, to be used for error output when working with the resource.

      Implementations are also encouraged to return this value from their toString method.

      Specified by:
      getDescription in interface Resource
      See Also:
      Object.toString()