001/** 002 * Copyright 2010-2014 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.common.util.spring.env; 017 018import org.kohsuke.MetaInfServices; 019import org.springframework.core.env.AbstractEnvironment; 020import org.springframework.core.env.Environment; 021import org.springframework.core.env.MutablePropertySources; 022import org.springframework.core.env.PropertySource; 023 024/** 025 * This environment contains both system properties and environment variables and automatically checks both whenever a property is requested. 026 * 027 * <pre> 028 * foo.barBaz -> env.FOO_BAR_BAZ 029 * FOO_BAR_BAZ 030 * env.foo_bar_baz 031 * foo_bar_baz 032 * </pre> 033 */ 034@MetaInfServices(Environment.class) 035public class SysEnvEnvironment extends AbstractEnvironment { 036 037 public SysEnvEnvironment() { 038 PropertySource<?> source = new SysEnvPropertySource(); 039 MutablePropertySources sources = super.getPropertySources(); 040 sources.addFirst(source); 041 } 042 043}