Skip to content

oswaldobapvicjr/confectory

confectory-logo

Contributors GitHub Workflow Status Coverage License Maven Central Javadoc

The modular, multi-format configuration framework for Java applications.


Overview

Confectory is a modular framework designed to hide the complexity of handling multiple configuration files for Java applications in general, providing a reliable and fast API for parsing data from different sources (file or URL) in a variety of formats, and allowing data access using a unified query language.

Overview diagram

Features

  • Easy configuration setup via intuitive API
  • Simple data query using JSONPath, XPath, or user-defined beans
  • Support for the best providers available in the community (e.g.: Jackson, GSON)
  • Multiple configuration formats (e.g.: XML, JSON, or YAML) with custom precedence levels
  • Lazy loading of configuration sources

Examples

1. Load data from a local Properties file in the classpath:

Configuration<Properties> config = Configuration.<Properties>builder()
        .source(SourceFactory.classpathFileSource("myapp.properties"))
        .mapper(new PropertiesMapper())
        .build();

Then access document data using one of the getter methods, using keys:

System.out.println(config.getBoolean("web.enable"));

2. Load data from a JSON document in a Web server:

Configuration<JSONObject> config = Configuration.<JSONObject>builder()
        .source("http://time.jsontest.com")
        .mapper(new JSONObjectMapper())
        .build();

Then access document data using JSONPath expressions:

System.out.println(config.getString("$.time"));

ℹ️ Find more examples in the wiki.

How to include it

Confectory was designed to work with the lowest-possible number of transitive dependencies. So, we offer separate modules that can be selected according to the client needs, optimizing your application:

Module Providers Properties XML JSON YAML TOML
confectory-core Java + json-smart
confectory-datamapper-json-org Json.org
confectory-datamapper-gson Google Gson
confectory-datamapper-jackson2-json Jackson 2
confectory-datamapper-jackson2-toml Jackson 2
confectory-datamapper-jackson2-xml Jackson 2
confectory-datamapper-jackson2-yaml Jackson 2
confectory-datamapper-snakeyaml SnakeYAML

Contributing

If you want to contribute to the Confectory project, check the issues page, or write an e-mail to oswaldo@obvj.net.

Confectory uses GitHub Actions for CI/CD.


The Confectory logo and the file-factory animation were created with Inkscape and Natron, both free and open-source Software tools.