@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2022 the original author or authors .
* Copyright 2002 - 2023 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -17,8 +17,10 @@
@@ -17,8 +17,10 @@
package org.springframework.messaging.handler.invocation ;
import java.lang.annotation.Annotation ;
import java.lang.reflect.InvocationHandler ;
import java.lang.reflect.Method ;
import java.lang.reflect.Parameter ;
import java.lang.reflect.Proxy ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.List ;
@ -28,16 +30,14 @@ import java.util.function.Consumer;
@@ -28,16 +30,14 @@ import java.util.function.Consumer;
import java.util.function.Predicate ;
import java.util.function.Supplier ;
import org.aopalliance.intercept.MethodInterceptor ;
import org.apache.commons.logging.Log ;
import org.apache.commons.logging.LogFactory ;
import org.springframework.aop.framework.ProxyFactory ;
import org.springframework.aop.target.EmptyTargetSource ;
import org.springframework.cglib.core.SpringNamingPolicy ;
import org.springframework.cglib.proxy.Callback ;
import org.springframework.cglib.proxy.Enhancer ;
import org.springframework.cglib.proxy.Factory ;
import org.springframework.cglib.proxy.MethodInterceptor ;
import org.springframework.cglib.proxy.MethodProxy ;
import org.springframework.core.DefaultParameterNameDiscoverer ;
import org.springframework.core.MethodIntrospector ;
@ -123,6 +123,7 @@ import static java.util.stream.Collectors.joining;
@@ -123,6 +123,7 @@ import static java.util.stream.Collectors.joining;
* < / pre >
*
* @author Rossen Stoyanchev
* @author Juergen Hoeller
* @since 5 . 2
* /
public class ResolvableMethod {
@ -189,7 +190,6 @@ public class ResolvableMethod {
@@ -189,7 +190,6 @@ public class ResolvableMethod {
/ * *
* Filter on method arguments with annotation .
* See { @link org . springframework . web . method . MvcAnnotationPredicates } .
* /
@SafeVarargs
public final ArgResolver annot ( Predicate < MethodParameter > . . . filter ) {
@ -302,7 +302,6 @@ public class ResolvableMethod {
@@ -302,7 +302,6 @@ public class ResolvableMethod {
/ * *
* Filter on annotated methods .
* See { @link org . springframework . web . method . MvcAnnotationPredicates } .
* /
@SafeVarargs
public final Builder < T > annot ( Predicate < Method > . . . filters ) {
@ -313,7 +312,6 @@ public class ResolvableMethod {
@@ -313,7 +312,6 @@ public class ResolvableMethod {
/ * *
* Filter on methods annotated with the given annotation type .
* @see # annot ( Predicate [ ] )
* See { @link org . springframework . web . method . MvcAnnotationPredicates } .
* /
@SafeVarargs
public final Builder < T > annotPresent ( Class < ? extends Annotation > . . . annotationTypes ) {
@ -530,7 +528,6 @@ public class ResolvableMethod {
@@ -530,7 +528,6 @@ public class ResolvableMethod {
/ * *
* Filter on method arguments with annotations .
* See { @link org . springframework . web . method . MvcAnnotationPredicates } .
* /
@SafeVarargs
public final ArgResolver annot ( Predicate < MethodParameter > . . . filters ) {
@ -542,7 +539,6 @@ public class ResolvableMethod {
@@ -542,7 +539,6 @@ public class ResolvableMethod {
* Filter on method arguments that have the given annotations .
* @param annotationTypes the annotation types
* @see # annot ( Predicate [ ] )
* See { @link org . springframework . web . method . MvcAnnotationPredicates } .
* /
@SafeVarargs
public final ArgResolver annotPresent ( Class < ? extends Annotation > . . . annotationTypes ) {
@ -615,16 +611,10 @@ public class ResolvableMethod {
@@ -615,16 +611,10 @@ public class ResolvableMethod {
}
private static class MethodInvocationInterceptor
implements org . springframework . cglib . proxy . MethodInterceptor , MethodInterceptor {
private static class MethodInvocationInterceptor implements MethodInterceptor , InvocationHandler {
private Method invokedMethod ;
Method getInvokedMethod ( ) {
return this . invokedMethod ;
}
@Override
@Nullable
public Object intercept ( Object object , Method method , Object [ ] args , MethodProxy proxy ) {
@ -639,20 +629,23 @@ public class ResolvableMethod {
@@ -639,20 +629,23 @@ public class ResolvableMethod {
@Override
@Nullable
public Object invoke ( org . aopalliance . intercept . MethodInvocation inv ) throws Throwable {
return intercept ( inv . getThis ( ) , inv . getMethod ( ) , inv . getArguments ( ) , null ) ;
public Object invoke ( Object proxy , Method method , Object [ ] args ) throws Throwable {
return intercept ( proxy , method , args , null ) ;
}
Method getInvokedMethod ( ) {
return this . invokedMethod ;
}
}
@SuppressWarnings ( "unchecked" )
private static < T > T initProxy ( Class < ? > type , MethodInvocationInterceptor interceptor ) {
Assert . notNull ( type , "'type' must not be null" ) ;
if ( type . isInterface ( ) ) {
ProxyFactory factory = new ProxyFactory ( EmptyTargetSource . INSTANCE ) ;
factory . addInterface ( type ) ;
factory . addInterface ( Supplier . class ) ;
factory . addAdvice ( interceptor ) ;
return ( T ) factory . getProxy ( ) ;
return ( T ) Proxy . newProxyInstance ( type . getClassLoader ( ) ,
new Class < ? > [ ] { type , Supplier . class } ,
interceptor ) ;
}
else {