Removed JDK 1.6 usage

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3830 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Arjen Poutsma 2010-12-22 10:23:34 +00:00
parent c84ffae75c
commit a32894ca31
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"));

View File

@ -1,11 +1,11 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* 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,
@ -100,7 +100,7 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
// TODO: SPR-7508 extract createEnvironment() method; do also in GWAC
this.getEnvironment().getPropertySources().push(new ServletContextPropertySource(this.servletContext));
this.getEnvironment().getPropertySources().addFirst(new ServletContextPropertySource(this.servletContext));
}
public ServletContext getServletContext() {
@ -113,7 +113,7 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR
this.setServletContext(servletConfig.getServletContext());
}
// TODO: SPR-7508 extract createEnvironment() method; do also in GWAC
this.getEnvironment().getPropertySources().push(new ServletConfigPropertySource(servletConfig));
this.getEnvironment().getPropertySources().addFirst(new ServletConfigPropertySource(servletConfig));
}
public ServletConfig getServletConfig() {

View File

@ -1,11 +1,11 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* 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,
@ -160,7 +160,7 @@ public class GenericWebApplicationContext extends GenericApplicationContext
@Override
protected void onRefresh() {
this.themeSource = UiApplicationContextUtils.initThemeSource(this);
this.getEnvironment().getPropertySources().push(new ServletContextPropertySource(servletContext));
this.getEnvironment().getPropertySources().addFirst(new ServletContextPropertySource(servletContext));
}
public Theme getTheme(String themeName) {

View File

@ -1,11 +1,11 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* 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,
@ -17,7 +17,6 @@
package org.springframework.web.context.support;
import java.util.LinkedList;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
@ -170,8 +169,8 @@ public class StaticWebApplicationContext extends StaticApplicationContext
protected void onRefresh() {
this.themeSource = UiApplicationContextUtils.initThemeSource(this);
LinkedList<PropertySource<?>> propertySources = this.getEnvironment().getPropertySources();
propertySources.push(new ServletContextPropertySource(servletContext));
propertySources.push(new ServletConfigPropertySource(servletConfig));
propertySources.addFirst(new ServletContextPropertySource(servletContext));
propertySources.addFirst(new ServletConfigPropertySource(servletConfig));
}
public Theme getTheme(String themeName) {