Browse Source

Polishing

(cherry picked from commit c926ec4)
pull/1155/head
Juergen Hoeller 10 years ago
parent
commit
22ca7ac927
  1. 10
      spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
  2. 7
      spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java
  3. 21
      spring-context/src/main/java/org/springframework/scripting/config/ScriptBeanDefinitionParser.java
  4. 4
      spring-context/src/main/java/org/springframework/scripting/config/ScriptingDefaultsParser.java
  5. 6
      spring-jdbc/src/main/java/org/springframework/jdbc/datasource/ConnectionHolder.java
  6. 4
      spring-jms/src/main/java/org/springframework/jms/config/JcaListenerContainerParser.java
  7. 12
      spring-web/src/main/java/org/springframework/http/HttpHeaders.java
  8. 5
      spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolver.java
  9. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java

10
spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

@ -616,10 +616,12 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
@Override @Override
public void registerResolvableDependency(Class<?> dependencyType, Object autowiredValue) { public void registerResolvableDependency(Class<?> dependencyType, Object autowiredValue) {
Assert.notNull(dependencyType, "Type must not be null"); Assert.notNull(dependencyType, "Dependency type must not be null");
if (autowiredValue != null) { if (autowiredValue != null) {
Assert.isTrue((autowiredValue instanceof ObjectFactory || dependencyType.isInstance(autowiredValue)), if (!(autowiredValue instanceof ObjectFactory || dependencyType.isInstance(autowiredValue))) {
"Value [" + autowiredValue + "] does not implement specified type [" + dependencyType.getName() + "]"); throw new IllegalArgumentException("Value [" + autowiredValue +
"] does not implement specified dependency type [" + dependencyType.getName() + "]");
}
this.resolvableDependencies.put(dependencyType, autowiredValue); this.resolvableDependencies.put(dependencyType, autowiredValue);
} }
} }
@ -1545,7 +1547,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
sources.add(factoryMethod); sources.add(factoryMethod);
} }
Class<?> targetType = beanDefinition.getTargetType(); Class<?> targetType = beanDefinition.getTargetType();
if (targetType != null && !targetType.equals(obj.getClass())) { if (targetType != null && targetType != obj.getClass()) {
sources.add(targetType); sources.add(targetType);
} }
return sources.toArray(new Object[sources.size()]); return sources.toArray(new Object[sources.size()]);

7
spring-context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java

@ -42,6 +42,7 @@ import org.springframework.util.StringUtils;
* <li>"0 0 * * * *" = the top of every hour of every day.</li> * <li>"0 0 * * * *" = the top of every hour of every day.</li>
* <li>"*&#47;10 * * * * *" = every ten seconds.</li> * <li>"*&#47;10 * * * * *" = every ten seconds.</li>
* <li>"0 0 8-10 * * *" = 8, 9 and 10 o'clock of every day.</li> * <li>"0 0 8-10 * * *" = 8, 9 and 10 o'clock of every day.</li>
* <li>"0 * 6,19 * * *" = 6:00 AM and 7:00 PM every day.</li>
* <li>"0 0/30 8-10 * * *" = 8:00, 8:30, 9:00, 9:30 and 10 o'clock every day.</li> * <li>"0 0/30 8-10 * * *" = 8:00, 8:30, 9:00, 9:30 and 10 o'clock every day.</li>
* <li>"0 0 9-17 * * MON-FRI" = on the hour nine-to-five weekdays</li> * <li>"0 0 9-17 * * MON-FRI" = on the hour nine-to-five weekdays</li>
* <li>"0 0 0 25 12 ?" = every Christmas Day at midnight</li> * <li>"0 0 0 25 12 ?" = every Christmas Day at midnight</li>
@ -115,7 +116,7 @@ public class CronSequenceGenerator {
/* /*
The plan: The plan:
1 Round up to the next whole second 1 Start with whole second (rounding up if necessary)
2 If seconds match move on, otherwise find the next match: 2 If seconds match move on, otherwise find the next match:
2.1 If next match is in the next minute then roll forwards 2.1 If next match is in the next minute then roll forwards
@ -127,8 +128,6 @@ public class CronSequenceGenerator {
4 If hour matches move on, otherwise find the next match 4 If hour matches move on, otherwise find the next match
4.1 If next match is in the next day then roll forwards, 4.1 If next match is in the next day then roll forwards,
4.2 Reset the minutes and seconds and go to 2 4.2 Reset the minutes and seconds and go to 2
...
*/ */
Calendar calendar = new GregorianCalendar(); Calendar calendar = new GregorianCalendar();
@ -409,7 +408,7 @@ public class CronSequenceGenerator {
@Override @Override
public String toString() { public String toString() {
return (getClass().getSimpleName() + ": " + this.expression); return getClass().getSimpleName() + ": " + this.expression;
} }
} }

21
spring-context/src/main/java/org/springframework/scripting/config/ScriptBeanDefinitionParser.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -35,17 +35,17 @@ import org.springframework.util.xml.DomUtils;
/** /**
* BeanDefinitionParser implementation for the '{@code <lang:groovy/>}', * BeanDefinitionParser implementation for the '{@code <lang:groovy/>}',
* '{@code <lang:jruby/>}' and '{@code <lang:bsh/>}' tags. * '{@code <lang:std/>}' and '{@code <lang:bsh/>}' tags.
* Allows for objects written using dynamic languages to be easily exposed with * Allows for objects written using dynamic languages to be easily exposed with
* the {@link org.springframework.beans.factory.BeanFactory}. * the {@link org.springframework.beans.factory.BeanFactory}.
* *
* <p>The script for each object can be specified either as a reference to the Resource * <p>The script for each object can be specified either as a reference to the
* containing it (using the '{@code script-source}' attribute) or inline in the XML configuration * resource containing it (using the '{@code script-source}' attribute) or inline
* itself (using the '{@code inline-script}' attribute. * in the XML configuration itself (using the '{@code inline-script}' attribute.
* *
* <p>By default, dynamic objects created with these tags are <strong>not</strong> refreshable. * <p>By default, dynamic objects created with these tags are <strong>not</strong>
* To enable refreshing, specify the refresh check delay for each object (in milliseconds) using the * refreshable. To enable refreshing, specify the refresh check delay for each
* '{@code refresh-check-delay}' attribute. * object (in milliseconds) using the '{@code refresh-check-delay}' attribute.
* *
* @author Rob Harrop * @author Rob Harrop
* @author Rod Johnson * @author Rod Johnson
@ -176,14 +176,13 @@ class ScriptBeanDefinitionParser extends AbstractBeanDefinitionParser {
// Attach any refresh metadata. // Attach any refresh metadata.
String refreshCheckDelay = element.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE); String refreshCheckDelay = element.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE);
if (StringUtils.hasText(refreshCheckDelay)) { if (StringUtils.hasText(refreshCheckDelay)) {
bd.setAttribute(ScriptFactoryPostProcessor.REFRESH_CHECK_DELAY_ATTRIBUTE, new Long(refreshCheckDelay)); bd.setAttribute(ScriptFactoryPostProcessor.REFRESH_CHECK_DELAY_ATTRIBUTE, Long.valueOf(refreshCheckDelay));
} }
// Attach any proxy target class metadata. // Attach any proxy target class metadata.
String proxyTargetClass = element.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE); String proxyTargetClass = element.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE);
if (StringUtils.hasText(proxyTargetClass)) { if (StringUtils.hasText(proxyTargetClass)) {
Boolean flag = new Boolean(proxyTargetClass); bd.setAttribute(ScriptFactoryPostProcessor.PROXY_TARGET_CLASS_ATTRIBUTE, Boolean.valueOf(proxyTargetClass));
bd.setAttribute(ScriptFactoryPostProcessor.PROXY_TARGET_CLASS_ATTRIBUTE, flag);
} }
// Add constructor arguments. // Add constructor arguments.

4
spring-context/src/main/java/org/springframework/scripting/config/ScriptingDefaultsParser.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -41,7 +41,7 @@ public class ScriptingDefaultsParser implements BeanDefinitionParser {
LangNamespaceUtils.registerScriptFactoryPostProcessorIfNecessary(parserContext.getRegistry()); LangNamespaceUtils.registerScriptFactoryPostProcessorIfNecessary(parserContext.getRegistry());
String refreshCheckDelay = element.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE); String refreshCheckDelay = element.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE);
if (StringUtils.hasText(refreshCheckDelay)) { if (StringUtils.hasText(refreshCheckDelay)) {
bd.getPropertyValues().add("defaultRefreshCheckDelay", new Long(refreshCheckDelay)); bd.getPropertyValues().add("defaultRefreshCheckDelay", Long.valueOf(refreshCheckDelay));
} }
String proxyTargetClass = element.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE); String proxyTargetClass = element.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE);
if (StringUtils.hasText(proxyTargetClass)) { if (StringUtils.hasText(proxyTargetClass)) {

6
spring-jdbc/src/main/java/org/springframework/jdbc/datasource/ConnectionHolder.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -161,9 +161,9 @@ public class ConnectionHolder extends ResourceHolderSupport {
*/ */
public boolean supportsSavepoints() throws SQLException { public boolean supportsSavepoints() throws SQLException {
if (this.savepointsSupported == null) { if (this.savepointsSupported == null) {
this.savepointsSupported = new Boolean(getConnection().getMetaData().supportsSavepoints()); this.savepointsSupported = getConnection().getMetaData().supportsSavepoints();
} }
return this.savepointsSupported.booleanValue(); return this.savepointsSupported;
} }
/** /**

4
spring-jms/src/main/java/org/springframework/jms/config/JcaListenerContainerParser.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -88,7 +88,7 @@ class JcaListenerContainerParser extends AbstractListenerContainerParser {
String prefetch = containerEle.getAttribute(PREFETCH_ATTRIBUTE); String prefetch = containerEle.getAttribute(PREFETCH_ATTRIBUTE);
if (StringUtils.hasText(prefetch)) { if (StringUtils.hasText(prefetch)) {
properties.add("prefetchSize", new Integer(prefetch)); properties.add("prefetchSize", Integer.valueOf(prefetch));
} }
return properties; return properties;

12
spring-web/src/main/java/org/springframework/http/HttpHeaders.java

@ -442,10 +442,10 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
} }
/** /**
* Returns the value of the {@code Access-Control-Allow-Credentials} response header. * Return the value of the {@code Access-Control-Allow-Credentials} response header.
*/ */
public boolean getAccessControlAllowCredentials() { public boolean getAccessControlAllowCredentials() {
return new Boolean(getFirst(ACCESS_CONTROL_ALLOW_CREDENTIALS)); return Boolean.parseBoolean(getFirst(ACCESS_CONTROL_ALLOW_CREDENTIALS));
} }
/** /**
@ -456,7 +456,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
} }
/** /**
* Returns the value of the {@code Access-Control-Allow-Headers} response header. * Return the value of the {@code Access-Control-Allow-Headers} response header.
*/ */
public List<String> getAccessControlAllowHeaders() { public List<String> getAccessControlAllowHeaders() {
return getFirstValueAsList(ACCESS_CONTROL_ALLOW_HEADERS); return getFirstValueAsList(ACCESS_CONTROL_ALLOW_HEADERS);
@ -509,7 +509,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
} }
/** /**
* Returns the value of the {@code Access-Control-Expose-Headers} response header. * Return the value of the {@code Access-Control-Expose-Headers} response header.
*/ */
public List<String> getAccessControlExposeHeaders() { public List<String> getAccessControlExposeHeaders() {
return getFirstValueAsList(ACCESS_CONTROL_EXPOSE_HEADERS); return getFirstValueAsList(ACCESS_CONTROL_EXPOSE_HEADERS);
@ -523,7 +523,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
} }
/** /**
* Returns the value of the {@code Access-Control-Max-Age} response header. * Return the value of the {@code Access-Control-Max-Age} response header.
* <p>Returns -1 when the max age is unknown. * <p>Returns -1 when the max age is unknown.
*/ */
public long getAccessControlMaxAge() { public long getAccessControlMaxAge() {
@ -539,7 +539,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
} }
/** /**
* Returns the value of the {@code Access-Control-Request-Headers} request header. * Return the value of the {@code Access-Control-Request-Headers} request header.
*/ */
public List<String> getAccessControlRequestHeaders() { public List<String> getAccessControlRequestHeaders() {
return getFirstValueAsList(ACCESS_CONTROL_REQUEST_HEADERS); return getFirstValueAsList(ACCESS_CONTROL_REQUEST_HEADERS);

5
spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolver.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -46,6 +46,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
/** The default name of the exception attribute: "exception". */ /** The default name of the exception attribute: "exception". */
public static final String DEFAULT_EXCEPTION_ATTRIBUTE = "exception"; public static final String DEFAULT_EXCEPTION_ATTRIBUTE = "exception";
private Properties exceptionMappings; private Properties exceptionMappings;
private Class<?>[] excludedExceptions; private Class<?>[] excludedExceptions;
@ -108,7 +109,7 @@ public class SimpleMappingExceptionResolver extends AbstractHandlerExceptionReso
public void setStatusCodes(Properties statusCodes) { public void setStatusCodes(Properties statusCodes) {
for (Enumeration<?> enumeration = statusCodes.propertyNames(); enumeration.hasMoreElements();) { for (Enumeration<?> enumeration = statusCodes.propertyNames(); enumeration.hasMoreElements();) {
String viewName = (String) enumeration.nextElement(); String viewName = (String) enumeration.nextElement();
Integer statusCode = new Integer(statusCodes.getProperty(viewName)); Integer statusCode = Integer.valueOf(statusCodes.getProperty(viewName));
this.statusCodes.put(viewName, statusCode); this.statusCodes.put(viewName, statusCode);
} }
} }

4
spring-webmvc/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -390,7 +390,7 @@ public abstract class AbstractJasperReportsView extends AbstractUrlBasedView {
else if (str.length() > 0 && Character.isDigit(str.charAt(0))) { else if (str.length() > 0 && Character.isDigit(str.charAt(0))) {
// Looks like a number... let's try. // Looks like a number... let's try.
try { try {
return new Integer(str); return Integer.valueOf(str);
} }
catch (NumberFormatException ex) { catch (NumberFormatException ex) {
// OK, then let's keep it as a String value. // OK, then let's keep it as a String value.

Loading…
Cancel
Save