Example usage for org.springframework.core.env PropertySource PropertySource

List of usage examples for org.springframework.core.env PropertySource PropertySource

Introduction

In this page you can find the example usage for org.springframework.core.env PropertySource PropertySource.

Prototype

public PropertySource(String name, T source) 

Source Link

Document

Create a new PropertySource with the given name and source object.

Usage

From source file:org.osiam.OsiamHome.java

public void configure(ConfigurableEnvironment environment) {
    String rawOsiamHome = environment.getProperty("osiam.home", System.getenv("HOME") + "/.osiam");
    checkState(!Strings.isNullOrEmpty(rawOsiamHome), "'osiam.home' is not set");
    osiamHome = Paths.get(rawOsiamHome).toAbsolutePath();
    environment.getPropertySources().addFirst(new PropertySource<Path>("osiamHome", osiamHome) {
        @Override/*from  w  w w. ja  v  a  2 s .c  o m*/
        public Object getProperty(String name) {
            return "osiam.home".equals(name) ? source.toString() : null;
        }
    });
}