Browse Source

PropertySource implementations perform conversion to String arrays via StringUtils (getting rid of EMPTY_NAMES_ARRAY)

pull/634/head
Juergen Hoeller 11 years ago
parent
commit
b73c531527
  1. 2
      spring-core/src/main/java/org/springframework/core/env/EnumerablePropertySource.java
  2. 6
      spring-core/src/main/java/org/springframework/core/env/MapPropertySource.java
  3. 3
      spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java
  4. 7
      spring-web/src/main/java/org/springframework/web/context/support/ServletConfigPropertySource.java
  5. 8
      spring-web/src/main/java/org/springframework/web/context/support/ServletContextPropertySource.java
  6. 7
      spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/context/PortletConfigPropertySource.java
  7. 7
      spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/context/PortletContextPropertySource.java

2
spring-core/src/main/java/org/springframework/core/env/EnumerablePropertySource.java vendored

@ -45,8 +45,6 @@ import org.springframework.util.Assert; @@ -45,8 +45,6 @@ import org.springframework.util.Assert;
*/
public abstract class EnumerablePropertySource<T> extends PropertySource<T> {
protected static final String[] EMPTY_NAMES_ARRAY = new String[0];
protected final Log logger = LogFactory.getLog(getClass());

6
spring-core/src/main/java/org/springframework/core/env/MapPropertySource.java vendored

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2014 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.
@ -18,6 +18,8 @@ package org.springframework.core.env; @@ -18,6 +18,8 @@ package org.springframework.core.env;
import java.util.Map;
import org.springframework.util.StringUtils;
/**
* {@link PropertySource} that reads keys and values from a {@code Map} object.
*
@ -38,7 +40,7 @@ public class MapPropertySource extends EnumerablePropertySource<Map<String, Obje @@ -38,7 +40,7 @@ public class MapPropertySource extends EnumerablePropertySource<Map<String, Obje
@Override
public String[] getPropertyNames() {
return this.source.keySet().toArray(EMPTY_NAMES_ARRAY);
return StringUtils.toStringArray(this.source.keySet());
}
}

3
spring-core/src/main/java/org/springframework/core/env/MutablePropertySources.java vendored

@ -21,6 +21,7 @@ import java.util.LinkedList; @@ -21,6 +21,7 @@ import java.util.LinkedList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@ -187,7 +188,7 @@ public class MutablePropertySources implements PropertySources { @@ -187,7 +188,7 @@ public class MutablePropertySources implements PropertySources {
}
@Override
public synchronized String toString() {
public String toString() {
String[] names = new String[this.size()];
for (int i=0; i < size(); i++) {
names[i] = this.propertySourceList.get(i).getName();

7
spring-web/src/main/java/org/springframework/web/context/support/ServletConfigPropertySource.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2014 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.
@ -20,7 +20,7 @@ import javax.servlet.ServletConfig; @@ -20,7 +20,7 @@ import javax.servlet.ServletConfig;
import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.PropertySource;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
/**
* {@link PropertySource} that reads init parameters from a {@link ServletConfig} object.
@ -37,8 +37,7 @@ public class ServletConfigPropertySource extends EnumerablePropertySource<Servle @@ -37,8 +37,7 @@ public class ServletConfigPropertySource extends EnumerablePropertySource<Servle
@Override
public String[] getPropertyNames() {
return CollectionUtils.toArray(
this.source.getInitParameterNames(), EMPTY_NAMES_ARRAY);
return StringUtils.toStringArray(this.source.getInitParameterNames());
}
@Override

8
spring-web/src/main/java/org/springframework/web/context/support/ServletContextPropertySource.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@ -20,7 +20,7 @@ import javax.servlet.ServletContext; @@ -20,7 +20,7 @@ import javax.servlet.ServletContext;
import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.PropertySource;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
/**
* {@link PropertySource} that reads init parameters from a {@link ServletContext} object.
@ -37,12 +37,12 @@ public class ServletContextPropertySource extends EnumerablePropertySource<Servl @@ -37,12 +37,12 @@ public class ServletContextPropertySource extends EnumerablePropertySource<Servl
@Override
public String[] getPropertyNames() {
return CollectionUtils.toArray(
this.source.getInitParameterNames(), EMPTY_NAMES_ARRAY);
return StringUtils.toStringArray(this.source.getInitParameterNames());
}
@Override
public String getProperty(String name) {
return this.source.getInitParameter(name);
}
}

7
spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/context/PortletConfigPropertySource.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2014 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.
@ -20,7 +20,7 @@ import javax.portlet.PortletConfig; @@ -20,7 +20,7 @@ import javax.portlet.PortletConfig;
import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.PropertySource;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
/**
* {@link PropertySource} that reads init parameters from a {@link PortletConfig} object.
@ -37,11 +37,12 @@ public class PortletConfigPropertySource extends EnumerablePropertySource<Portle @@ -37,11 +37,12 @@ public class PortletConfigPropertySource extends EnumerablePropertySource<Portle
@Override
public String[] getPropertyNames() {
return CollectionUtils.toArray(this.source.getInitParameterNames(), EMPTY_NAMES_ARRAY);
return StringUtils.toStringArray(this.source.getInitParameterNames());
}
@Override
public String getProperty(String name) {
return this.source.getInitParameter(name);
}
}

7
spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/context/PortletContextPropertySource.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2014 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.
@ -20,7 +20,7 @@ import javax.portlet.PortletContext; @@ -20,7 +20,7 @@ import javax.portlet.PortletContext;
import org.springframework.core.env.EnumerablePropertySource;
import org.springframework.core.env.PropertySource;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
/**
* {@link PropertySource} that reads init parameters from a {@link PortletContext} object.
@ -37,11 +37,12 @@ public class PortletContextPropertySource extends EnumerablePropertySource<Portl @@ -37,11 +37,12 @@ public class PortletContextPropertySource extends EnumerablePropertySource<Portl
@Override
public String[] getPropertyNames() {
return CollectionUtils.toArray(this.source.getInitParameterNames(), EMPTY_NAMES_ARRAY);
return StringUtils.toStringArray(this.source.getInitParameterNames());
}
@Override
public String getProperty(String name) {
return this.source.getInitParameter(name);
}
}

Loading…
Cancel
Save