Class URLSource<T>

  • All Implemented Interfaces:
    Source<T>
    Direct Known Subclasses:
    ClasspathFileSource

    public class URLSource<T>
    extends AbstractSource<T>
    implements Source<T>
    A specialized configuration source implementation that loads contents from a URL, that can be a local file or a Web resource.

    The syntax of a URL is defined by RFC-2396 (Uniform Resource Identifiers: Generic Syntax), and amended by RFC-2732 (Format for Literal IPv6 Addresses in URLs).

    Examples of valid URLs:

    • file:///etc/fstab (local host)
    • file://ftp.server.com/pub/files/foo.xml
    • http://www.server.com:1080/myservice/config.json
    • http://192.168.0.10:1080/config?field1=value1&field2=value2
    Since:
    0.4.0
    Author:
    oswaldo.bapvic.jr (Oswaldo Junior)
    • Constructor Detail

      • URLSource

        public URLSource​(String string)
        Builds a new configuration source for a specific URL.
        Parameters:
        string - the string to parse as URL for this configuration source
        Throws:
        ConfigurationSourceException - if the specified URL can not be parsed
    • Method Detail

      • load

        public T load​(Mapper<T> mapper)
        Description copied from interface: Source
        Applies a specific configuration loading strategy and returns a mapped bean containing the retrieved data, throwing an exception if the operation fails.
        Specified by:
        load in interface Source<T>
        Parameters:
        mapper - the Mapper to be applied on the source input stream
        Returns:
        the loaded configuration data