Skip to content

Latest commit

 

History

History
126 lines (93 loc) · 6.58 KB

README.md

File metadata and controls

126 lines (93 loc) · 6.58 KB

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.

flowchart TD
    User(["User"]) -->|"property"| c((("`**confectory**`"))):::larger
    User -->|"xpath"| c
    User -->|"jsonpath"| c

    c-->properties("properties"):::condensed
    c-->ini("INI"):::expanded
    c-->xml("XML"):::expanded
    c-->json("JSON"):::expanded
    c-->yaml("YAML"):::expanded
    c-->toml("TOML"):::expanded

    classDef larger font-size:18pt
    classDef condensed letter-spacing:-0.8px
    classDef expanded letter-spacing:1.2px
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(["User"]) -- 1️⃣ build --> Configuration
  object -- 2️⃣ load --> file["📄 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(["User"]) -- 1️⃣ build --> Configuration
  object -- 2️⃣ load --> file["🌍 http://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.

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.