Class InterceptingExecutableInvoker


  • @API(status=INTERNAL,
         since="5.0")
    public class InterceptingExecutableInvoker
    extends java.lang.Object
    InterceptingExecutableInvoker encapsulates the invocation of a Executable (i.e., method or constructor), including support for dynamic resolution of method parameters via ParameterResolvers.
    Since:
    5.0
    • Constructor Detail

      • InterceptingExecutableInvoker

        public InterceptingExecutableInvoker()
    • Method Detail

      • invoke

        public <T> T invoke​(java.lang.reflect.Constructor<T> constructor,
                            java.util.Optional<java.lang.Object> outerInstance,
                            org.junit.jupiter.api.extension.ExtensionContext extensionContext,
                            ExtensionRegistry extensionRegistry,
                            InterceptingExecutableInvoker.ReflectiveInterceptorCall<java.lang.reflect.Constructor<T>,​T> interceptorCall)
        Invoke the supplied constructor with the supplied outer instance and dynamic parameter resolution.
        Parameters:
        constructor - the constructor to invoke and resolve parameters for
        outerInstance - the outer instance to supply as the first argument to the constructor; empty, for top-level classes
        extensionContext - the current ExtensionContext
        extensionRegistry - the ExtensionRegistry to retrieve ParameterResolvers from
        interceptorCall - the call for intercepting this constructor invocation via all registered interceptors
      • invoke

        public <T> T invoke​(java.lang.reflect.Method method,
                            java.lang.Object target,
                            org.junit.jupiter.api.extension.ExtensionContext extensionContext,
                            ExtensionRegistry extensionRegistry,
                            InterceptingExecutableInvoker.ReflectiveInterceptorCall<java.lang.reflect.Method,​T> interceptorCall)
        Invoke the supplied method with dynamic parameter resolution.
        Parameters:
        method - the method to invoke and resolve parameters for
        target - the target on which the executable will be invoked, potentially wrapped in an Optional; can be null or an empty Optional for a static method
        extensionContext - the current ExtensionContext
        extensionRegistry - the ExtensionRegistry to retrieve ParameterResolvers from
        interceptorCall - the call for intercepting this method invocation via all registered interceptors
      • invoke

        private <E extends java.lang.reflect.Executable,​T> T invoke​(org.junit.jupiter.api.extension.InvocationInterceptor.Invocation<T> originalInvocation,
                                                                          org.junit.jupiter.api.extension.ReflectiveInvocationContext<E> invocationContext,
                                                                          org.junit.jupiter.api.extension.ExtensionContext extensionContext,
                                                                          ExtensionRegistry extensionRegistry,
                                                                          InterceptingExecutableInvoker.ReflectiveInterceptorCall<E,​T> call)