Skip to content

Commit

Permalink
Cache Interceptor signature result
Browse files Browse the repository at this point in the history
  • Loading branch information
Puppy4C committed Jan 18, 2025
1 parent 7653c44 commit 930f8c5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/org/apache/ibatis/plugin/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.ibatis.reflection.ExceptionUtil;

Expand All @@ -30,6 +31,8 @@
*/
public class Plugin implements InvocationHandler {

private static final Map<Class<? extends Interceptor>, Map<Class<?>, Set<Method>>> signatureMapCache = new ConcurrentHashMap<>();

private final Object target;
private final Interceptor interceptor;
private final Map<Class<?>, Set<Method>> signatureMap;
Expand Down Expand Up @@ -64,6 +67,10 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
}

private static Map<Class<?>, Set<Method>> getSignatureMap(Interceptor interceptor) {
return signatureMapCache.computeIfAbsent(interceptor.getClass(), (clazz) -> createSignatureMap(interceptor));
}

private static Map<Class<?>, Set<Method>> createSignatureMap(Interceptor interceptor) {
Intercepts interceptsAnnotation = interceptor.getClass().getAnnotation(Intercepts.class);
// issue #251
if (interceptsAnnotation == null) {
Expand Down

0 comments on commit 930f8c5

Please sign in to comment.