spring-framework / org.springframework.beans

Package org.springframework.beans

Types

BeanUtils

abstract class BeanUtils

Static convenience methods for JavaBeans: for instantiating beans, checking bean property types, copying bean properties, etc.

Mainly for use within the framework, but to some degree also useful for application classes.

CachedIntrospectionResults

open class CachedIntrospectionResults

Internal class that caches JavaBeans java.beans.PropertyDescriptor information for a Java class. Not intended for direct use by application code.

Necessary for own caching of descriptors within the application's ClassLoader, rather than rely on the JDK's system-wide BeanInfo cache (in order to avoid leaks on ClassLoader shutdown).

Information is cached statically, so we don't need to create new objects of this class for every JavaBean we manipulate. Hence, this class implements the factory design pattern, using a private constructor and a static #forClass(Class) factory method to obtain instances.

Note that for caching to work effectively, some preconditions need to be met: Prefer an arrangement where the Spring jars live in the same ClassLoader as the application classes, which allows for clean caching along with the application's lifecycle in any case. For a web application, consider declaring a local org.springframework.web.util.IntrospectorCleanupListener in web.xml in case of a multi-ClassLoader layout, which will allow for effective caching as well.

In case of a non-clean ClassLoader arrangement without a cleanup listener having been set up, this class will fall back to a weak-reference-based caching model that recreates much-requested entries every time the garbage collector removed them. In such a scenario, consider the #IGNORE_BEANINFO_PROPERTY_NAME system property.

DirectFieldAccessor

open class DirectFieldAccessor : AbstractNestablePropertyAccessor

ConfigurablePropertyAccessor implementation that directly accesses instance fields. Allows for direct binding to fields instead of going through JavaBean setters.

As of Spring 4.2, the vast majority of the BeanWrapper features have been merged to AbstractPropertyAccessor, which means that property traversal as well as collections and map access is now supported here as well.

A DirectFieldAccessor's default for the "extractOldValueForEditor" setting is "true", since a field can always be read without side effects.

ExtendedBeanInfoFactory

open class ExtendedBeanInfoFactory : BeanInfoFactory, Ordered

BeanInfoFactory implementation that evaluates whether bean classes have "non-standard" JavaBeans setter methods and are thus candidates for introspection by Spring's (package-visible) ExtendedBeanInfo implementation.

Ordered at Ordered#LOWEST_PRECEDENCE to allow other user-defined BeanInfoFactory types to take precedence.

Mergeable

interface Mergeable

Interface representing an object whose value set can be merged with that of a parent object.

PropertyAccessor

interface PropertyAccessor

Common interface for classes that can access named properties (such as bean properties of an object or fields in an object) Serves as base interface for BeanWrapper.

PropertyAccessorUtils

abstract class PropertyAccessorUtils

Utility methods for classes that perform bean property access according to the PropertyAccessor interface.

PropertyMatches

abstract class PropertyMatches

Helper class for calculating property matches, according to a configurable distance. Provide the list of potential matches and an easy way to generate an error message. Works for both java bean properties and fields.

Mainly for use within the framework and in particular the binding facility.

PropertyValue

open class PropertyValue : BeanMetadataAttributeAccessor, Serializable

Object to hold information and value for an individual bean property. Using an object here, rather than just storing all properties in a map keyed by property name, allows for more flexibility, and the ability to handle indexed properties etc in an optimized way.

Note that the value doesn't need to be the final required type: A BeanWrapper implementation should handle any necessary conversion, as this object doesn't know anything about the objects it will be applied to.

PropertyValuesEditor

open class PropertyValuesEditor : PropertyEditorSupport

java.beans.PropertyEditor for a PropertyValues object.

The required format is defined in the java.util.Properties documentation. Each property must be on a new line.

The present implementation relies on a org.springframework.beans.propertyeditors.PropertiesEditor underneath.

Exceptions

BeanInstantiationException

open class BeanInstantiationException : FatalBeanException

Exception thrown when instantiation of a bean failed. Carries the offending bean class.

ConversionNotSupportedException

open class ConversionNotSupportedException : TypeMismatchException

Exception thrown when no suitable editor or converter can be found for a bean property.

FatalBeanException

open class FatalBeanException : BeansException

Thrown on an unrecoverable problem encountered in the beans packages or sub-packages, e.g. bad class or field.

MethodInvocationException

open class MethodInvocationException : PropertyAccessException

Thrown when a bean property getter or setter method throws an exception, analogous to an InvocationTargetException.

NotReadablePropertyException

open class NotReadablePropertyException : InvalidPropertyException

Exception thrown on an attempt to get the value of a property that isn't readable, because there's no getter method.

NotWritablePropertyException

open class NotWritablePropertyException : InvalidPropertyException

Exception thrown on an attempt to set the value of a property that is not writable (typically because there is no setter method).

NullValueInNestedPathException

open class NullValueInNestedPathException : InvalidPropertyException

Exception thrown when navigation of a valid nested property path encounters a NullPointerException.

For example, navigating "spouse.age" could fail because the spouse property of the target object has a null value.

PropertyAccessException

abstract class PropertyAccessException : BeansException

Superclass for exceptions related to a property access, such as type mismatch or invocation target exception.

PropertyBatchUpdateException

open class PropertyBatchUpdateException : BeansException

Combined exception, composed of individual PropertyAccessException instances. An object of this class is created at the beginning of the binding process, and errors added to it as necessary.

The binding process continues when it encounters application-level PropertyAccessExceptions, applying those changes that can be applied and storing rejected changes in an object of this class.

TypeMismatchException

open class TypeMismatchException : PropertyAccessException

Exception thrown on a type mismatch when trying to set a bean property.