org.springframework.aop.framework

Class ReflectiveMethodInvocation

  • java.lang.Object
    • org.springframework.aop.framework.ReflectiveMethodInvocation
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      protected java.lang.Object[] arguments 
      protected java.util.List<?> interceptorsAndDynamicMethodMatchers
      List of MethodInterceptor and InterceptorAndDynamicMethodMatcher that need dynamic checks.
      protected java.lang.reflect.Method method 
      protected java.lang.Object proxy 
      protected java.lang.Object target 
    • Constructor Summary

      Constructors 
      Modifier Constructor and Description
      protected ReflectiveMethodInvocation(java.lang.Object proxy, java.lang.Object target, java.lang.reflect.Method method, java.lang.Object[] arguments, java.lang.Class<?> targetClass, java.util.List<java.lang.Object> interceptorsAndDynamicMethodMatchers)
      Construct a new ReflectiveMethodInvocation with the given arguments.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.Object[] getArguments()
      Get the arguments as an array object.
      java.lang.reflect.Method getMethod()
      Return the method invoked on the proxied interface.
      java.lang.Object getProxy()
      Return the proxy that this method invocation was made through.
      java.lang.reflect.AccessibleObject getStaticPart()
      Return the static part of this joinpoint.
      java.lang.Object getThis()
      Return the object that holds the current joinpoint's static part.
      java.lang.Object getUserAttribute(java.lang.String key)
      Return the value of the specified user attribute.
      java.util.Map<java.lang.String,java.lang.Object> getUserAttributes()
      Return user attributes associated with this invocation.
      MethodInvocation invocableClone()
      This implementation returns a shallow copy of this invocation object, including an independent copy of the original arguments array.
      MethodInvocation invocableClone(java.lang.Object... arguments)
      This implementation returns a shallow copy of this invocation object, using the given arguments array for the clone.
      protected java.lang.Object invokeJoinpoint()
      Invoke the joinpoint using reflection.
      java.lang.Object proceed()
      Proceed to the next interceptor in the chain.
      void setArguments(java.lang.Object... arguments)
      Set the arguments to be used on subsequent invocations in the any advice in this chain.
      void setUserAttribute(java.lang.String key, java.lang.Object value)
      Add the specified user attribute with the given value to this invocation.
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • proxy

        protected final java.lang.Object proxy
      • target

        @Nullable
        protected final java.lang.Object target
      • method

        protected final java.lang.reflect.Method method
      • arguments

        protected java.lang.Object[] arguments
      • interceptorsAndDynamicMethodMatchers

        protected final java.util.List<?> interceptorsAndDynamicMethodMatchers
        List of MethodInterceptor and InterceptorAndDynamicMethodMatcher that need dynamic checks.
    • Constructor Detail

      • ReflectiveMethodInvocation

        protected ReflectiveMethodInvocation(java.lang.Object proxy,
                                             @Nullable
                                             java.lang.Object target,
                                             java.lang.reflect.Method method,
                                             @Nullable
                                             java.lang.Object[] arguments,
                                             @Nullable
                                             java.lang.Class<?> targetClass,
                                             java.util.List<java.lang.Object> interceptorsAndDynamicMethodMatchers)
        Construct a new ReflectiveMethodInvocation with the given arguments.
        Parameters:
        proxy - the proxy object that the invocation was made on
        target - the target object to invoke
        method - the method to invoke
        arguments - the arguments to invoke the method with
        targetClass - the target class, for MethodMatcher invocations
        interceptorsAndDynamicMethodMatchers - interceptors that should be applied, along with any InterceptorAndDynamicMethodMatchers that need evaluation at runtime. MethodMatchers included in this struct must already have been found to have matched as far as was possibly statically. Passing an array might be about 10% faster, but would complicate the code. And it would work only for static pointcuts.
    • Method Detail

      • getProxy

        public final java.lang.Object getProxy()
        Description copied from interface: ProxyMethodInvocation
        Return the proxy that this method invocation was made through.
        Specified by:
        getProxy in interface ProxyMethodInvocation
        Returns:
        the original proxy object
      • getThis

        @Nullable
        public final java.lang.Object getThis()
        Description copied from interface: Joinpoint
        Return the object that holds the current joinpoint's static part.

        For instance, the target object for an invocation.

        Specified by:
        getThis in interface Joinpoint
        Returns:
        the object (can be null if the accessible object is static)
      • getStaticPart

        public final java.lang.reflect.AccessibleObject getStaticPart()
        Description copied from interface: Joinpoint
        Return the static part of this joinpoint.

        The static part is an accessible object on which a chain of interceptors are installed.

        Specified by:
        getStaticPart in interface Joinpoint
      • getMethod

        public final java.lang.reflect.Method getMethod()
        Return the method invoked on the proxied interface. May or may not correspond with a method invoked on an underlying implementation of that interface.
        Specified by:
        getMethod in interface MethodInvocation
        Returns:
        the method being called
      • getArguments

        public final java.lang.Object[] getArguments()
        Description copied from interface: Invocation
        Get the arguments as an array object. It is possible to change element values within this array to change the arguments.
        Specified by:
        getArguments in interface Invocation
        Returns:
        the argument of the invocation
      • setArguments

        public void setArguments(java.lang.Object... arguments)
        Description copied from interface: ProxyMethodInvocation
        Set the arguments to be used on subsequent invocations in the any advice in this chain.
        Specified by:
        setArguments in interface ProxyMethodInvocation
        Parameters:
        arguments - the argument array
      • proceed

        @Nullable
        public java.lang.Object proceed()
                                           throws java.lang.Throwable
        Description copied from interface: Joinpoint
        Proceed to the next interceptor in the chain.

        The implementation and the semantics of this method depends on the actual joinpoint type (see the children interfaces).

        Specified by:
        proceed in interface Joinpoint
        Returns:
        see the children interfaces' proceed definition
        Throws:
        java.lang.Throwable - if the joinpoint throws an exception
      • invokeJoinpoint

        @Nullable
        protected java.lang.Object invokeJoinpoint()
                                                      throws java.lang.Throwable
        Invoke the joinpoint using reflection. Subclasses can override this to use custom invocation.
        Returns:
        the return value of the joinpoint
        Throws:
        java.lang.Throwable - if invoking the joinpoint resulted in an exception
      • invocableClone

        public MethodInvocation invocableClone()
        This implementation returns a shallow copy of this invocation object, including an independent copy of the original arguments array.

        We want a shallow copy in this case: We want to use the same interceptor chain and other object references, but we want an independent value for the current interceptor index.

        Specified by:
        invocableClone in interface ProxyMethodInvocation
        Returns:
        an invocable clone of this invocation. proceed() can be called once per clone.
        See Also:
        Object.clone()
      • invocableClone

        public MethodInvocation invocableClone(java.lang.Object... arguments)
        This implementation returns a shallow copy of this invocation object, using the given arguments array for the clone.

        We want a shallow copy in this case: We want to use the same interceptor chain and other object references, but we want an independent value for the current interceptor index.

        Specified by:
        invocableClone in interface ProxyMethodInvocation
        Parameters:
        arguments - the arguments that the cloned invocation is supposed to use, overriding the original arguments
        Returns:
        an invocable clone of this invocation. proceed() can be called once per clone.
        See Also:
        Object.clone()
      • setUserAttribute

        public void setUserAttribute(java.lang.String key,
                                     @Nullable
                                     java.lang.Object value)
        Description copied from interface: ProxyMethodInvocation
        Add the specified user attribute with the given value to this invocation.

        Such attributes are not used within the AOP framework itself. They are just kept as part of the invocation object, for use in special interceptors.

        Specified by:
        setUserAttribute in interface ProxyMethodInvocation
        Parameters:
        key - the name of the attribute
        value - the value of the attribute, or null to reset it
      • getUserAttributes

        public java.util.Map<java.lang.String,java.lang.Object> getUserAttributes()
        Return user attributes associated with this invocation. This method provides an invocation-bound alternative to a ThreadLocal.

        This map is initialized lazily and is not used in the AOP framework itself.

        Returns:
        any user attributes associated with this invocation (never null)
      • toString

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