Skip to content

Adds support for YAML (YAML Ain't Markup Language) in your Java CDI and DeltaSpike application. Registers a configuration source to the DeltaSpike configuration mechanism to turn your YAML configurations to CDI aware properties.

License

Notifications You must be signed in to change notification settings

SethFalco/yaml4deltaspike

Repository files navigation

YAML4DeltaSpike

Deprecation Notice

This project is no longer maintained, as I'm working on migrating YAML support upstream into DeltaSpike.

About

Provides YAML configuration support for the DeltaSpike configuration mechanism, and uses snakeyaml to bind the properties to an implementation of the MapConfigSource.

Getting Started

Import

Visit YAML4DeltaSpike on Maven Central, and follow the instructions for your build system of choice to add YAML4DeltaSpike to your project.

Usage

The configuration should work out of the box once you've added the dependency to your project.

YAML4Deltaspike automatically looks for an application.yml in the root of the classpath and loads it without any additional configuration.

If you want a custom file name, or load order, you can extend and override the YamlConfigSource class, and follow the instructions on the DeltaSpike documentation:

public class CustomYamlConfigSource extends YamlConfigSource {

    public CustomYamlConfigSource() {
        super("custom_application.yml", false);
    }
}

Examples

There are two modes for the YamlConfigSource, non-indexed (default) and indexed.

application:
  name: YAML4DeltaSpike
  messages:
    - source: source0
      target: target0
    - source: source1
      target: target1

Non-Indexed (Default)

Non-indexed mode will convert arrays of nested objects to a series of lists.

application.name=YAML4DeltaSpike
application.messages.source=source0,source1
application.messages.target=target0,target1

Indexed

Indexed mode will convert arrays of nested objects to the property key, but with a 0-indexed suffix, similarly to that of an array-access in Java.

application.name=YAML4DeltaSpike
application.messages[0].source=source0
application.messages[0].target=target0
application.messages[1].source=source1
application.messages[1].target=target1

About

Adds support for YAML (YAML Ain't Markup Language) in your Java CDI and DeltaSpike application. Registers a configuration source to the DeltaSpike configuration mechanism to turn your YAML configurations to CDI aware properties.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Languages