Coder Social home page Coder Social logo

java-config's Introduction

Configuration

the purpose and some advanced usage of this library is outlined in this post so I will not duplicate it here.

Basic usage

Installation

Maven

<dependency>
	<groupId>hu.meza.tools</groupId>
    <artifactId>config</artifactId>
    <version>[1.1.0,)</version>
</dependency>

Others

Check out instructions on Maven central

Usage for the lazy

To get the best value out of this lib with the least amount of effort, use this as it is: (and add your own configuration directives)

import hu.meza.tools.config.Config;
import hu.meza.tools.config.ConfigurationNotFoundException;
import hu.meza.tools.config.Loaders.SystemPropertiesConfiguration;
import hu.meza.tools.config.Required;

import java.io.File;

public class Configuration {

	private Config config = new Config();

	public Configuration() {
		config.addHighOrder(new SystemPropertiesConfiguration());

		String configFilename = config.get("config", "config.properties");
		File file = new File(configFilename);
		config.add(new Required(file));
	}

	public String someConfiguration() {
		return config.get("someConfiguration");
	}
}

This will require you to either have a config.properties next to the project, or to set a config parameter and specify the location of the file.

It is not advised to expose the internal Config object to the rest of the code, so when you have to rename config parameters, you can be sure that this will be the only place you need to look at.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.