Overview

The juneau-config library contains a powerful API for creating and using INI-style config files.

##### Example configuration file:

# A set of entries [Section1] # An integer key1 = 1 # A boolean key2 = true # An array key3 = 1,2,3 # A POJO key4 = http://bar

Config files are accessed through the {@link oaj.config.Config} class which are created through the {@link oaj.config.ConfigBuilder} class. Builder creator methods are provided on the Config class:

// Create a Config object Config c = Config.create().name("MyConfig.cfg").build(); // Shortcut Config c = Config.create("MyConfig.cfg").build();

Once instantiated, reading values from the config are simple:

// Read values from section #1 int key1 = c.getInt("Section1/key1"); boolean key2 = c.getBoolean("Section1/key2"); int[] key3 = c.getObject("Section1/key3", int[].class); URL key4 = c.getObject("Section1/key4", URL.class);

The config language may look simple, but it is a very powerful feature with many capabilities including:

- Support for storing and retrieving any of the following data types:
  - Primitives
  - POJOs
  - Beans
  - Arrays, Maps, and Collections of anything
  - Binary data
- Transactional modifications with commit/rollback capabilities.
- A listener API.
- Filesystem watcher integration allowing changes on the file system to be reflected in real-time.
- Modifications through the Config class (e.g. add/remove/modify sections and keys, add/remove comments and whitespace, etc...) DO NOT cause loss of formatting in the file.
  All existing whitespace and comments are preserved for you!
- Value encoding for added security.
- Support for SVL variables.
- Directly populate beans from config sections.
- Accessing config sections through Java interface proxies.
- An extensible storage API allows you to write your own config storage (e.g. storage in databases or the cloud).