org.springframework.beans.factory.support
Class AutowireUtils

java.lang.Object
  extended by org.springframework.beans.factory.support.AutowireUtils

abstract class AutowireUtils
extends java.lang.Object

Utility class that contains various methods useful for the implementation of autowire-capable bean factories.

Since:
1.1.2
Author:
Juergen Hoeller, Mark Fisher
See Also:
AbstractAutowireCapableBeanFactory

Nested Class Summary
private static class AutowireUtils.ObjectFactoryDelegatingInvocationHandler
          Reflective InvocationHandler for lazy access to the current target object.
 
Constructor Summary
AutowireUtils()
           
 
Method Summary
static boolean isExcludedFromDependencyCheck(java.beans.PropertyDescriptor pd)
          Determine whether the given bean property is excluded from dependency checks.
static boolean isSetterDefinedInInterface(java.beans.PropertyDescriptor pd, java.util.Set<java.lang.Class> interfaces)
          Return whether the setter method of the given bean property is defined in any of the given interfaces.
static java.lang.Object resolveAutowiringValue(java.lang.Object autowiringValue, java.lang.Class requiredType)
          Resolve the given autowiring value against the given required type, e.g.
static void sortConstructors(java.lang.reflect.Constructor[] constructors)
          Sort the given constructors, preferring public constructors and "greedy" ones with a maximum number of arguments.
static void sortFactoryMethods(java.lang.reflect.Method[] factoryMethods)
          Sort the given factory methods, preferring public methods and "greedy" ones with a maximum of arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutowireUtils

AutowireUtils()
Method Detail

sortConstructors

public static void sortConstructors(java.lang.reflect.Constructor[] constructors)
Sort the given constructors, preferring public constructors and "greedy" ones with a maximum number of arguments. The result will contain public constructors first, with decreasing number of arguments, then non-public constructors, again with decreasing number of arguments.

Parameters:
constructors - the constructor array to sort

sortFactoryMethods

public static void sortFactoryMethods(java.lang.reflect.Method[] factoryMethods)
Sort the given factory methods, preferring public methods and "greedy" ones with a maximum of arguments. The result will contain public methods first, with decreasing number of arguments, then non-public methods, again with decreasing number of arguments.

Parameters:
factoryMethods - the factory method array to sort

isExcludedFromDependencyCheck

public static boolean isExcludedFromDependencyCheck(java.beans.PropertyDescriptor pd)
Determine whether the given bean property is excluded from dependency checks.

This implementation excludes properties defined by CGLIB.

Parameters:
pd - the PropertyDescriptor of the bean property
Returns:
whether the bean property is excluded

isSetterDefinedInInterface

public static boolean isSetterDefinedInInterface(java.beans.PropertyDescriptor pd,
                                                 java.util.Set<java.lang.Class> interfaces)
Return whether the setter method of the given bean property is defined in any of the given interfaces.

Parameters:
pd - the PropertyDescriptor of the bean property
interfaces - the Set of interfaces (Class objects)
Returns:
whether the setter method is defined by an interface

resolveAutowiringValue

public static java.lang.Object resolveAutowiringValue(java.lang.Object autowiringValue,
                                                      java.lang.Class requiredType)
Resolve the given autowiring value against the given required type, e.g. an ObjectFactory value to its actual object result.

Parameters:
autowiringValue - the value to resolve
requiredType - the type to assign the result to
Returns:
the resolved value