All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lyders.properties.sample.SampleApp Maven / Gradle / Ivy

Go to download

This ApplicationProperties Java package provides a fast and easily configurable application.properties loader that mimics some key features of the Spring Boot application.properties loader. This package allows for multi-level overloading of properties based on a basename and optional suffix by searching the classpath, optional configurable file paths along with the JNDI server container context. The class [ApplicationPropertiesConfig](src/main/java/com/lyders/application-properties/ApplicationPropertiesConfig.java) controls the features of the overloading of properties such as the base name of the properties file, an optional suffix that allows for the loading of environment-specific or scenario-specific property files as needed. The following features are supported: * Names of properties files can be customized * Locations of properties files can be customized. The following path types are supported: * class path * file system paths * JNDI environment naming context (e.g., Servlet/JSP running under Tomcat) * Environment-specific property files can override the values in default properties files via a "suffix"

The newest version!
package com.lyders.properties.sample;

import com.lyders.properties.ApplicationProperties;
import com.lyders.properties.ApplicationPropertiesConfig;

import java.io.FileNotFoundException;

public class SampleApp {

    public static void main(String[] args) throws FileNotFoundException {
        SampleApp sampleApp = new SampleApp();
        sampleApp.sampleRun();
    }

    public void sampleRun() throws FileNotFoundException {
        ApplicationPropertiesConfig cfg = new ApplicationPropertiesConfig(null, "-unittest",
                ApplicationPropertiesConfig.LoadClassPathRootPropertiesAsDefaults.NO);
        ApplicationProperties properties = new ApplicationProperties(cfg, "conf");
        System.out.println("...................");
        System.out.println("Properties per file");
        System.out.println("...................");
        properties.printAllSourcesAndProperties(System.out::println);

        System.out.println("...................");
        System.out.println("Final property values");
        System.out.println("...................");
        properties.printAllProperties(System.out::println);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy