Class ConfigurationSourceProviderWithFallback

  • All Implemented Interfaces:
    io.dropwizard.configuration.ConfigurationSourceProvider

    public class ConfigurationSourceProviderWithFallback
    extends Object
    implements io.dropwizard.configuration.ConfigurationSourceProvider
    This allows for trying to resolve configuration source from several types of locations. If the first provider throws an IOException, a second attempt is done with a fallback provider. The typical composition of providers is to first try using a FileConfigurationSourceProvider, and then a ResourceConfigurationSourceProvider.
     
     new ConfigurationSourceProviderWithFallback(
         new FileConfigurationSourceProvider(),
         new ResourceConfigurationSourceProvider()
     )
     
     
    • Constructor Detail

      • ConfigurationSourceProviderWithFallback

        public ConfigurationSourceProviderWithFallback​(io.dropwizard.configuration.ConfigurationSourceProvider main,
                                                       io.dropwizard.configuration.ConfigurationSourceProvider fallback)
    • Method Detail

      • open

        public final InputStream open​(String path)
                               throws IOException
        Specified by:
        open in interface io.dropwizard.configuration.ConfigurationSourceProvider
        Throws:
        ConfigurationSourceNotFoundException - if both providers fails with IOException trying to resolve a configuration source from the given path. The thrown exception will contain the exception from the main provider as cause, and the exception from the second provider as suppressed.
        IOException