polishing

This commit is contained in:
Juergen Hoeller
2011-02-10 22:19:10 +00:00
parent 6bfead259e
commit 03190950d1
10 changed files with 47 additions and 43 deletions

View File

@@ -16,10 +16,7 @@
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 java.lang.String.*;
import java.security.AccessControlException;
import java.util.Arrays;
import java.util.LinkedHashSet;
@@ -28,9 +25,11 @@ 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.util.Assert;
import org.springframework.util.StringUtils;
import static org.springframework.util.StringUtils.*;
/**
* Abstract base class for {@link Environment} implementations.
@@ -67,7 +66,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
//---------------------------------------------------------------------
public String[] getActiveProfiles() {
return this.doGetActiveProfiles().toArray(new String[]{});
return StringUtils.toStringArray(doGetActiveProfiles());
}
protected Set<String> doGetActiveProfiles() {
@@ -86,7 +85,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
}
public String[] getDefaultProfiles() {
return this.doGetDefaultProfiles().toArray(new String[]{});
return StringUtils.toStringArray(doGetDefaultProfiles());
}
protected Set<String> doGetDefaultProfiles() {

View File

@@ -87,16 +87,15 @@ public class DefaultEnvironment extends AbstractEnvironment {
/**
* Create a new {@code Environment} populated with property sources in the following order:
* <ul>
* <li>{@value #SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME}
* <li>{@value #SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME}
* <li>{@value #SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME}
* <li>{@value #SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME}
* </ul>
*
* <p>Properties present in {@value #SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME} will
* take precedence over those in {@value #SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME}.
*/
public DefaultEnvironment() {
this.getPropertySources().addFirst(new MapPropertySource(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, this.getSystemEnvironment()));
this.getPropertySources().addFirst(new MapPropertySource(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, this.getSystemProperties()));
getPropertySources().addFirst(new MapPropertySource(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, getSystemEnvironment()));
getPropertySources().addFirst(new MapPropertySource(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, getSystemProperties()));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 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.
@@ -16,8 +16,6 @@
package org.springframework.core.env;
/**
* Interface for resolving properties against any underlying source.
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* Copyright 2002-2011 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.
@@ -27,6 +27,9 @@ package org.springframework.util;
*/
public interface ErrorHandler {
/**
* Handle the given error, possibly rethrowing it as a fatal exception
*/
void handleError(Throwable t);
}