org.springframework.beans.factory.support
Class AutowireUtils

java.lang.Object
  extended byorg.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 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


Copyright (C) 2003-2004 The Spring Framework Project.