Skip to content

About

The modular configuration framework for Java applications

Topics

Resources

Code of conduct

Security policy

Stars

13 stars

Watchers

2 watching

Forks

Latest commit

 

History

309 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

confectory-logo

Java 11+ Contributors GitHub Workflow Status Coverage License Maven Central Version 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 simplified data access using standard query languages.

flowchart TD
    User@{ shape: stadium, label: ["👤\n**User**"]}
    c@{ shape: procs, label: ["**confectory**"]}
    User -->|"property"| c
    User -->|"xpath"| c
    User -->|"jsonpath"| c

    c-->properties@{shape: data-store, label: "properties"}
    c-->ini@{shape: data-store}
    c-->xml@{shape: data-store}
    c-->json@{shape: data-store}
    c-->yaml@{shape: data-store}
    c-->toml@{shape: data-store}

    classDef larger font-size:24pt
    class c larger
Loading

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:

flowchart LR
  subgraph Configuration
    direction LR
    object["☕ Properties"]
  end
  u@{ shape: text, label: ["👤\nUser"]} -- 1️⃣ build --> Configuration
  object -- 2️⃣ load -->  file@{ shape: doc, label: "📄 application.properties"}
  u -- 3️⃣ get(key) --> Configuration
Loading
Configuration config = Configuration.builder()
        .source("classpath://application.properties")
        .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:

flowchart LR
  subgraph Configuration
    direction LR
    object["⭕ JSONObject"]
  end
  u@{ shape: text, label: ["👤\nUser"]} -- 1️⃣ build --> Configuration
  object -- 2️⃣ load --> file@{ shape: cloud, label: "🌍 time.jsontest.com"}
  u -- 3️⃣ get(jsonpath) --> Configuration
Loading
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's 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-saxon12 Saxon-HE 12 ☑
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.

Thanks to all the people who have already contributed!

Made with contrib.rocks


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.

About

The modular configuration framework for Java applications

Topics

Resources

Code of conduct

Security policy

Stars

13 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages