All Projects → yyvess → Guice-configuration

yyvess / Guice-configuration

Licence: Apache-2.0 license
Guice configuration module allows inject values from files as JSON, HOCON and Properties format

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Guice-configuration

gen-cisco
🧨 Generates Cisco scripts based on YAML files
Stars: ✭ 29 (+3.57%)
Mutual labels:  yaml
go-config
Configuration file loader for Go
Stars: ✭ 27 (-3.57%)
Mutual labels:  yaml
pipeline
Spline is a tool that is capable of running locally as well as part of well known pipelines like Jenkins (Jenkinsfile), Travis CI (.travis.yml) or similar ones.
Stars: ✭ 29 (+3.57%)
Mutual labels:  yaml
Prinder
Free Pull Request reminder for Github. Has configurations to post reminders to Slack and email along with jinja templating
Stars: ✭ 21 (-25%)
Mutual labels:  yaml
kahoy
Simple Kubernetes raw manifests deployment tool
Stars: ✭ 33 (+17.86%)
Mutual labels:  yaml
HsYAML
YAML 1.2 implementation in pure Haskell
Stars: ✭ 50 (+78.57%)
Mutual labels:  yaml
zettelgeist
A less-is-more (distributed) notetaking application. Designed specifically for those who prefer working with the command line and want to do crazy indexing, analysis, and transformation of notes. Aimed at but not limited to scholarly research projects.
Stars: ✭ 25 (-10.71%)
Mutual labels:  yaml
bafi
Universal JSON, BSON, YAML, CSV, XML converter with templates
Stars: ✭ 65 (+132.14%)
Mutual labels:  yaml
icingaweb2-module-fileshipper
Provide CSV, JSON, XML and YAML files as an Import Source for the Icinga Director and optionally ship hand-crafted additional Icinga2 config files
Stars: ✭ 25 (-10.71%)
Mutual labels:  yaml
ryaml
Python yaml library using Rust
Stars: ✭ 14 (-50%)
Mutual labels:  yaml
coqpit
Simple but maybe too simple config management through python data classes. We use it for machine learning.
Stars: ✭ 67 (+139.29%)
Mutual labels:  yaml
obp-apis
OpenBankingProject.ch Community APIs
Stars: ✭ 18 (-35.71%)
Mutual labels:  yaml
AUCR
Analyst Unknown Cyber Range - a micro web service framework
Stars: ✭ 24 (-14.29%)
Mutual labels:  yaml
remark-frontmatter
remark plugin to support frontmatter (YAML, TOML, and more)
Stars: ✭ 167 (+496.43%)
Mutual labels:  yaml
dynamic.yaml
DEPRECATED: YAML-based data transformations
Stars: ✭ 14 (-50%)
Mutual labels:  yaml
eslint-plugin-yml
This ESLint plugin provides linting rules for YAML.
Stars: ✭ 40 (+42.86%)
Mutual labels:  yaml
consulator
Import and synchronize your Consul KV data from JSON and YAML
Stars: ✭ 27 (-3.57%)
Mutual labels:  yaml
gohit
Run curl commands from yaml files
Stars: ✭ 19 (-32.14%)
Mutual labels:  yaml
statics
Base class and modules for YAML backed static models.
Stars: ✭ 41 (+46.43%)
Mutual labels:  yaml
elk
🦌 Minimalist yaml based task runner
Stars: ✭ 43 (+53.57%)
Mutual labels:  yaml

Guice configuration module, JSON, HOCON & Properties formats supported, build on the top of Typesafe config

Maven Central semantic-release

Sonar Status Coverage

Guice configuration

Overview

  • Guice injection
  • JSON, HOCON and Properties formats
  • Substitutions ${foo.bar}
  • Validation

Binary Releases

You can find published releases on Maven Central.

	<dependency>
		<groupId>net.jmob</groupId>
		<artifactId>guice.conf</artifactId>
		<version>v1.5.0</version>
	</dependency>

Optionally, to active validation, you must import a validator like Hibernate validator

    <dependency>
        <groupId>org.hibernate.validator</groupId>
        <artifactId>hibernate-validator-cdi</artifactId>
        <version>6.2.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.el</artifactId>
        <version>3.0.0</version>
    </dependency>

Link for direct download if you don't use a dependency manager:

Quickstart

A configuration file app.json :

{
  "port": 8080,
  "complexEntries": {
    "hostname": "www.github.com",
    "aMap": {
      "key1": "value1",
      "key2": "value2"
    },
    "aList": [
      "value1",
      "value2"
    ]
  }
}

An interface where inject your structured configuration

   public interface MyServiceConfiguration {

      @Length(min = 5)
      String getHostname();
    
      Map<String, String> getAMap();
    
      List<String> getAList();
   }

A service where configuration should be inject

    @BindConfig(value = "app", syntax = JSON)
    public class Service {

        @InjectConfig
        private Optional<Integer> port;

        @InjectConfig("complexEntries")
        private MyServiceConfiguration config;

        public int getPort() {
            return port.orElse(0);
        }

        public ServiceConfiguration getConfig() {
            return config;
        }
    }
    public class GuiceModule extends AbstractModule {
        @Override
        protected void configure() {
            install(new ConfigurationModule());
            requestInjection(Service.class);
        }
    }

Configuration files are loaded of classpath by default

A directory can be specified to load configuration outside of classpath

    public class GuiceModule extends AbstractModule {
        @Override
        protected void configure() {
            install(new ConfigurationModule()
                .fromPath(new File("/etc")));
            requestInjection(Service.class);
        }
    }

Variables on your configuration file can be substitued with environment variables.

Substitution should be active with the option 'resolve'

@BindConfig(value = "config, resolve = true)
{
  myconfig: ${my.environement.property}
}

Please find more examples on src/test/samples

Supported types

  • boolean, Boolean
  • String
  • int, Integer, double, Double
  • List, Map, with typed value support
  • Optional<?>
  • Any Interface, a proxy of this interface is injected

References

License

The license is Apache 2.0, see LICENSE file.

Copyright (c) 2015-2016, Yves Galante

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].