001package org.kuali.common.util.spring.env;
002
003import org.kohsuke.MetaInfServices;
004import org.springframework.core.env.AbstractEnvironment;
005import org.springframework.core.env.Environment;
006import org.springframework.core.env.MutablePropertySources;
007import org.springframework.core.env.PropertySource;
008
009/**
010 * This environment contains both system properties and environment variables and automatically checks both whenever a property is requested.
011 * 
012 * <pre>
013 *   foo.barBaz -> env.FOO_BAR_BAZ
014 *                 FOO_BAR_BAZ
015 *                 env.foo_bar_baz
016 *                 foo_bar_baz
017 * </pre>
018 */
019@MetaInfServices(Environment.class)
020public class SysEnvEnvironment extends AbstractEnvironment {
021
022        public SysEnvEnvironment() {
023                PropertySource<?> source = new SysEnvPropertySource();
024                MutablePropertySources sources = super.getPropertySources();
025                sources.addFirst(source);
026        }
027
028}