org.springframework.beans.factory.support

Class 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.

    Methods eligible for lookup override must not have arguments.

    Since:
    1.1
    Author:
    Rod Johnson, Juergen Hoeller
    • Constructor Summary

      Constructors 
      Constructor and Description
      LookupOverride(java.lang.reflect.Method method, java.lang.String beanName)
      Construct a new LookupOverride.
      LookupOverride(java.lang.String methodName, java.lang.String beanName)
      Construct a new LookupOverride.
    • Constructor Detail

      • LookupOverride

        public LookupOverride(java.lang.String methodName,
                              @Nullable
                              java.lang.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)
      • LookupOverride

        public LookupOverride(java.lang.reflect.Method method,
                              @Nullable
                              java.lang.String beanName)
        Construct a new LookupOverride.
        Parameters:
        method - the method to override
        beanName - the name of the bean in the current BeanFactory that the overridden method should return (may be null)
    • Method Detail

      • getBeanName

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

        public boolean matches(java.lang.reflect.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(java.lang.Object other)
        Overrides:
        equals in class MethodOverride
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object