Class LookupOverride

java.lang.Object
org.springframework.beans.factory.support.MethodOverride
org.springframework.beans.factory.support.LookupOverride
All Implemented Interfaces:
BeanMetadataElement

public class LookupOverride extends MethodOverride
Represents an override of a method that looks up an object in the same IoC context, either by bean name or by bean type (based on the declared method return type).

Methods eligible for lookup override may declare arguments in which case the given arguments are passed to the bean retrieval operation.

Since:
1.1
Author:
Rod Johnson, Juergen Hoeller
See Also:
  • Constructor Details

    • LookupOverride

      public LookupOverride(String methodName, @Nullable String beanName)
      Construct a new LookupOverride.
      Parameters:
      methodName - the name of the method to override
      beanName - the name of the bean in the current BeanFactory that the overridden method should return (may be null for type-based bean retrieval)
    • LookupOverride

      public LookupOverride(Method method, @Nullable String beanName)
      Construct a new LookupOverride.
      Parameters:
      method - the method declaration to override
      beanName - the name of the bean in the current BeanFactory that the overridden method should return (may be null for type-based bean retrieval)
  • Method Details

    • getBeanName

      @Nullable public String getBeanName()
      Return the name of the bean that should be returned by this method.
    • matches

      public boolean matches(Method method)
      Match the specified method by Method reference or method name.

      For backwards compatibility reasons, in a scenario with overloaded non-abstract methods of the given name, only the no-arg variant of a method will be turned into a container-driven lookup method.

      In case of a provided Method, only straight matches will be considered, usually demarcated by the @Lookup annotation.

      Specified by:
      matches in class MethodOverride
      Parameters:
      method - the method to check
      Returns:
      whether this override matches the given method
    • equals

      public boolean equals(@Nullable Object other)
      Overrides:
      equals in class MethodOverride
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class MethodOverride
    • toString

      public String toString()
      Overrides:
      toString in class Object