Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
src/main better yaml Apr 7, 2016
README.md use mix of yaml and properties in classpath-bind example Apr 7, 2016
build.gradle upgrade cfg4j to 4.0.0 Aug 10, 2015

README.md

cfg4j sample app (uses classpath as configuration store)

App demonstrating how to access configuration stored in a classpath files using cfg4j library. Uses multiple configuration files.

Usage

> cd cfg4j-sample-apps/
> ./gradlew build
> java -jar classpath-bind/build/libs/classpath-bind-1.0.0-SNAPSHOT.jar

Code snippets

Configuration beans - see ConfigBeans.java

// Specify which files to load. Configuration from both files will be merged.
ConfigFilesProvider configFilesProvider = () -> Arrays.asList(new File("application.yaml"), new File("otherConfig.properties"));

// Use classpath repository as configuration store
ConfigurationSource source = new ClasspathConfigurationSource(configFilesProvider);

// Create provider
return new ConfigurationProviderBuilder()
    .withConfigurationSource(source)
    .build();
}

Obtain configuration - see MainController.java

// Define configuration interface 
public interface ReksioConfig {
  URL homepage();
  ...
}

ReksioConfig reksioConfig = configurationProvider.bind("reksio", ReksioConfig.class);
URL url = reksioConfig.homepage();