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.service; 017 018import java.util.List; 019 020import org.kuali.common.util.spring.SpringUtils; 021import org.springframework.core.env.PropertySource; 022 023@Deprecated 024public class PropertySourceContext { 025 026 public static final boolean DEFAULT_REMOVE_EXISTING_SOURCES = false; 027 public static final boolean DEFAULT_LAST_ONE_IN_WINS = true; 028 public static final PropertySourceAddPriority DEFAULT_PRIORITY = PropertySourceAddPriority.LAST; 029 030 // If true, any existing property sources are removed and replaced by the list from this context 031 boolean removeExistingSources = DEFAULT_REMOVE_EXISTING_SOURCES; 032 033 // If true, the last PropertySource in the list has the highest priority 034 // That is to say, Spring will search for property values starting at the bottom of the list and work its way upwards, stopping as soon as it has a match 035 boolean lastOneInWins = DEFAULT_LAST_ONE_IN_WINS; 036 037 // Can add property sources before or after existing property sources 038 PropertySourceAddPriority priority = DEFAULT_PRIORITY; 039 040 // The list of property source objects to add to the environment 041 List<PropertySource<?>> sources; 042 043 public PropertySourceContext() { 044 this(null); 045 } 046 047 public PropertySourceContext(List<PropertySource<?>> sources) { 048 this(sources, DEFAULT_REMOVE_EXISTING_SOURCES); 049 } 050 051 public PropertySourceContext(PropertySource<?> source, boolean removeExistingSources) { 052 this(SpringUtils.asList(source), removeExistingSources); 053 } 054 055 public PropertySourceContext(List<PropertySource<?>> sources, boolean removeExistingSources) { 056 super(); 057 this.sources = sources; 058 this.removeExistingSources = removeExistingSources; 059 } 060 061 public boolean isRemoveExistingSources() { 062 return removeExistingSources; 063 } 064 065 public void setRemoveExistingSources(boolean removeExistingSources) { 066 this.removeExistingSources = removeExistingSources; 067 } 068 069 public boolean isLastOneInWins() { 070 return lastOneInWins; 071 } 072 073 public void setLastOneInWins(boolean lastOneInWins) { 074 this.lastOneInWins = lastOneInWins; 075 } 076 077 public List<PropertySource<?>> getSources() { 078 return sources; 079 } 080 081 public void setSources(List<PropertySource<?>> sources) { 082 this.sources = sources; 083 } 084 085 public PropertySourceAddPriority getPriority() { 086 return priority; 087 } 088 089 public void setPriority(PropertySourceAddPriority priority) { 090 this.priority = priority; 091 } 092 093}