org.springframework.beans.factory.support
Class AutowireUtils

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

public abstract class AutowireUtils
extends Object

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

Since:
1.1.2
Author:
Juergen Hoeller
See Also:
AbstractAutowireCapableBeanFactory

Constructor Summary
AutowireUtils()
           
 
Method Summary
static int getTypeDifferenceWeight(Class[] argTypes, Object[] args)
          Determine a weight that represents the class hierarchy difference between types and arguments.
static boolean isExcludedFromDependencyCheck(PropertyDescriptor pd)
          Determine whether the given bean property is excluded from dependency checks.
static boolean isSetterDefinedInInterface(PropertyDescriptor pd, Set interfaces)
          Return whether the setter method of the given bean property is defined in any of the given interfaces.
static void sortConstructors(Constructor[] constructors)
          Sort the given constructors, preferring public constructors 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

public AutowireUtils()
Method Detail

sortConstructors

public static void sortConstructors(Constructor[] constructors)
Sort the given constructors, preferring public constructors and "greedy" ones with a maximum 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

getTypeDifferenceWeight

public static int getTypeDifferenceWeight(Class[] argTypes,
                                          Object[] args)
Determine a weight that represents the class hierarchy difference between types and arguments. A direct match, i.e. type Integer -> arg of class Integer, does not increase the result - all direct matches means weight 0. A match between type Object and arg of class Integer would increase the weight by 2, due to the superclass 2 steps up in the hierarchy (i.e. Object) being the last one that still matches the required type Object. Type Number and class Integer would increase the weight by 1 accordingly, due to the superclass 1 step up the hierarchy (i.e. Number) still matching the required type Number. Therefore, with an arg of type Integer, a constructor (Integer) would be preferred to a constructor (Number) which would in turn be preferred to a constructor (Object). All argument weights get accumulated.

Parameters:
argTypes - the argument types to match
args - the arguments to match
Returns:
the accumulated weight for all arguments

isExcludedFromDependencyCheck

public static boolean isExcludedFromDependencyCheck(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(PropertyDescriptor pd,
                                                 Set 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


Copyright (c) 2002-2007 The Spring Framework Project.