sdlang-dev / SDL

SDL (Simple Declarative Language) for java
11 stars 1 forks source link

SDLang as a PropertySource for Spring Framework #62

Open SingingBush opened 9 months ago

SingingBush commented 9 months ago

I've started a branch off of the annotation branch (as it requires multi-module project) which allows users to easily use SDL in Spring projects. https://github.com/sdlang-dev/SDL/tree/feature/spring

basic usage would be to set some config:

    @Configuration
    @PropertySource(value = "classpath:my-test.sdl", factory = SdlPropertySourceFactory.class)
    public static class MySpringConfiguration {}

and then if the SDL file had a node such as author "Peter Parker" email="peter@example.org" active=true

the nodes value and attributes could be injected using:

    @Value("${author}")
    private String authorValue; // will result in "Peter Parker" being injected

    @Value("${author|email}") // note that I may change this to "${author['email']}"
    private String authorEmailAttr;

    @Value("${author|active}") // note that I may change this to "${author['active']}"
    private Boolean authorActiveAttr;