Covert InterceptorAndDynamicMethodMatcher to a record

This commit is contained in:
Sam Brannen 2023-03-05 13:33:04 +01:00
parent c9aba1eaad
commit 37458d28d9
2 changed files with 9 additions and 16 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 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.
@ -21,20 +21,13 @@ import org.aopalliance.intercept.MethodInterceptor;
import org.springframework.aop.MethodMatcher;
/**
* Internal framework class, combining a MethodInterceptor instance
* with a MethodMatcher for use as an element in the advisor chain.
* Internal framework record, combining a {@link MethodInterceptor} instance
* with a {@link MethodMatcher} for use as an element in the advisor chain.
*
* @author Rod Johnson
* @author Sam Brannen
* @param interceptor the {@code MethodInterceptor}
* @param matcher the {@code MethodMatcher}
*/
class InterceptorAndDynamicMethodMatcher {
final MethodInterceptor interceptor;
final MethodMatcher methodMatcher;
public InterceptorAndDynamicMethodMatcher(MethodInterceptor interceptor, MethodMatcher methodMatcher) {
this.interceptor = interceptor;
this.methodMatcher = methodMatcher;
}
record InterceptorAndDynamicMethodMatcher(MethodInterceptor interceptor, MethodMatcher matcher) {
}

View File

@ -169,8 +169,8 @@ public class ReflectiveMethodInvocation implements ProxyMethodInvocation, Clonea
// Evaluate dynamic method matcher here: static part will already have
// been evaluated and found to match.
Class<?> targetClass = (this.targetClass != null ? this.targetClass : this.method.getDeclaringClass());
if (dm.methodMatcher.matches(this.method, targetClass, this.arguments)) {
return dm.interceptor.invoke(this);
if (dm.matcher().matches(this.method, targetClass, this.arguments)) {
return dm.interceptor().invoke(this);
}
else {
// Dynamic matching failed.