diff --git a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java index 2f87b10a36..25e6f772fb 100644 --- a/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java +++ b/spring-beans/src/main/java/org/springframework/beans/ExtendedBeanInfo.java @@ -43,8 +43,10 @@ import org.springframework.util.ObjectUtils; * Decorator for a standard {@link BeanInfo} object, e.g. as created by * {@link Introspector#getBeanInfo(Class)}, designed to discover and register static * and/or non-void returning setter methods. For example: + * *
  * public class Bean {
+ *
  *     private Foo foo;
  *
  *     public Foo getFoo() {
@@ -56,6 +58,7 @@ import org.springframework.util.ObjectUtils;
  *         return this;
  *     }
  * }
+ * * The standard JavaBeans {@code Introspector} will discover the {@code getFoo} read * method, but will bypass the {@code #setFoo(Foo)} write method, because its non-void * returning signature does not comply with the JavaBeans specification. @@ -68,6 +71,7 @@ import org.springframework.util.ObjectUtils; * indexed properties are fully supported. * * @author Chris Beams + * @author Juergen Hoeller * @since 3.1 * @see #ExtendedBeanInfo(BeanInfo) * @see ExtendedBeanInfoFactory @@ -79,8 +83,7 @@ class ExtendedBeanInfo implements BeanInfo { private final BeanInfo delegate; - private final Set propertyDescriptors = - new TreeSet<>(new PropertyDescriptorComparator()); + private final Set propertyDescriptors = new TreeSet<>(new PropertyDescriptorComparator()); /** @@ -91,11 +94,9 @@ class ExtendedBeanInfo implements BeanInfo { * through its method descriptors to find any non-void returning write methods and * update or create the corresponding {@link PropertyDescriptor} for each one found. * @param delegate the wrapped {@code BeanInfo}, which is never modified - * @throws IntrospectionException if any problems occur creating and adding new - * property descriptors * @see #getPropertyDescriptors() */ - public ExtendedBeanInfo(BeanInfo delegate) throws IntrospectionException { + public ExtendedBeanInfo(BeanInfo delegate) { this.delegate = delegate; for (PropertyDescriptor pd : delegate.getPropertyDescriptors()) { try { @@ -213,9 +214,9 @@ class ExtendedBeanInfo implements BeanInfo { /** - * Return the set of {@link PropertyDescriptor}s from the wrapped {@link BeanInfo} - * object as well as {@code PropertyDescriptor}s for each non-void returning setter - * method found during construction. + * Return the set of {@link PropertyDescriptor PropertyDescriptors} from the wrapped + * {@link BeanInfo} object as well as {@code PropertyDescriptors} for each non-void + * returning setter method found during construction. * @see #ExtendedBeanInfo(BeanInfo) */ @Override @@ -259,6 +260,9 @@ class ExtendedBeanInfo implements BeanInfo { } + /** + * A simple {@link PropertyDescriptor}. + */ static class SimplePropertyDescriptor extends PropertyDescriptor { @Nullable @@ -278,7 +282,9 @@ class ExtendedBeanInfo implements BeanInfo { PropertyDescriptorUtils.copyNonMethodProperties(original, this); } - public SimplePropertyDescriptor(String propertyName, @Nullable Method readMethod, Method writeMethod) throws IntrospectionException { + public SimplePropertyDescriptor(String propertyName, @Nullable Method readMethod, Method writeMethod) + throws IntrospectionException { + super(propertyName, null, null); this.readMethod = readMethod; this.writeMethod = writeMethod; @@ -350,6 +356,9 @@ class ExtendedBeanInfo implements BeanInfo { } + /** + * A simple {@link IndexedPropertyDescriptor}. + */ static class SimpleIndexedPropertyDescriptor extends IndexedPropertyDescriptor { @Nullable @@ -379,8 +388,9 @@ class ExtendedBeanInfo implements BeanInfo { PropertyDescriptorUtils.copyNonMethodProperties(original, this); } - public SimpleIndexedPropertyDescriptor(String propertyName, @Nullable Method readMethod, @Nullable Method writeMethod, - @Nullable Method indexedReadMethod, Method indexedWriteMethod) throws IntrospectionException { + public SimpleIndexedPropertyDescriptor(String propertyName, @Nullable Method readMethod, + @Nullable Method writeMethod, @Nullable Method indexedReadMethod, Method indexedWriteMethod) + throws IntrospectionException { super(propertyName, null, null, null, null); this.readMethod = readMethod; diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java b/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java index 773d06542d..c549c9c475 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyDescriptorUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 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. @@ -30,14 +30,12 @@ import org.springframework.util.ObjectUtils; * @author Chris Beams * @author Juergen Hoeller */ -class PropertyDescriptorUtils { +abstract class PropertyDescriptorUtils { /** * See {@link java.beans.FeatureDescriptor}. */ - public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target) - throws IntrospectionException { - + public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target) { target.setExpert(source.isExpert()); target.setHidden(source.isHidden()); target.setPreferred(source.isPreferred()); diff --git a/spring-core/src/main/java/org/springframework/core/SpringVersion.java b/spring-core/src/main/java/org/springframework/core/SpringVersion.java index a8c7fcead5..3150d5feb5 100644 --- a/spring-core/src/main/java/org/springframework/core/SpringVersion.java +++ b/spring-core/src/main/java/org/springframework/core/SpringVersion.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 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. @@ -25,7 +25,7 @@ import org.springframework.lang.Nullable; *

Note that some ClassLoaders do not expose the package metadata, * hence this class might not be able to determine the Spring version * in all environments. Consider using a reflection-based check instead: - * For example, checking for the presence of a specific Spring 2.0 + * For example, checking for the presence of a specific Spring 5.0 * method that you intend to call. * * @author Juergen Hoeller