Removed JDK 1.6 usage

This commit is contained in:
Arjen Poutsma
2010-12-22 10:23:34 +00:00
parent 29a8ca4edc
commit 64c7549c70
5 changed files with 29 additions and 44 deletions

View File

@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,17 +16,9 @@
package org.springframework.core.env;
import static java.lang.String.format;
import static org.springframework.util.StringUtils.commaDelimitedListToSet;
import static org.springframework.util.StringUtils.trimAllWhitespace;
import static org.springframework.util.SystemPropertyUtils.PLACEHOLDER_PREFIX;
import static org.springframework.util.SystemPropertyUtils.PLACEHOLDER_SUFFIX;
import static org.springframework.util.SystemPropertyUtils.VALUE_SEPARATOR;
import java.security.AccessControlException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Map;
@@ -36,12 +28,17 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.ConversionServiceFactory;
import org.springframework.util.PropertyPlaceholderHelper;
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
import org.springframework.util.StringUtils;
import static java.lang.String.*;
import static org.springframework.util.StringUtils.*;
import static org.springframework.util.SystemPropertyUtils.*;
/**
* TODO SPR-7508: document
@@ -78,7 +75,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
}
public void addPropertySource(PropertySource<?> propertySource) {
propertySources.push(propertySource);
propertySources.addFirst(propertySource);
}
public void addPropertySource(String name, Properties properties) {
@@ -169,9 +166,8 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
public Properties asProperties() {
// TODO SPR-7508: refactor, simplify. only handles map-based propertysources right now.
Properties mergedProps = new Properties();
Iterator<PropertySource<?>> descendingIterator = getPropertySources().descendingIterator();
while (descendingIterator.hasNext()) {
PropertySource<?> propertySource = descendingIterator.next();
for (int i = propertySources.size() -1; i >= 0; i--) {
PropertySource<?> propertySource = propertySources.get(i);
Object object = propertySource.getSource();
if (object instanceof Map) {
for (Entry<?, ?> entry : ((Map<?, ?>)object).entrySet()) {

View File

@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -16,23 +16,6 @@
package org.springframework.core.env;
import static java.lang.String.format;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.matchers.JUnitMatchers.hasItem;
import static org.junit.matchers.JUnitMatchers.hasItems;
import static org.springframework.core.env.AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME;
import static org.springframework.core.env.AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME;
import static org.springframework.core.env.DefaultEnvironmentTests.CollectionMatchers.isEmpty;
import java.lang.reflect.Field;
import java.security.AccessControlException;
import java.security.Permission;
@@ -50,6 +33,13 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.internal.matchers.TypeSafeMatcher;
import static java.lang.String.format;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.junit.matchers.JUnitMatchers.*;
import static org.springframework.core.env.AbstractEnvironment.*;
import static org.springframework.core.env.DefaultEnvironmentTests.CollectionMatchers.*;
/**
* Unit tests for {@link DefaultEnvironment}.
*
@@ -89,7 +79,7 @@ public class DefaultEnvironmentTests {
// put 'system' at the front of the list
LinkedList<PropertySource<?>> propertySources = env.getPropertySources();
propertySources.push(propertySources.remove(propertySources.indexOf(PropertySource.named("system"))));
propertySources.addFirst(propertySources.remove(propertySources.indexOf(PropertySource.named("system"))));
// 'system' now has precedence
assertThat(env.getProperty("foo"), equalTo("systemValue"));