From ea40541193b38c741dfbdb6c25256f94dd2c3a74 Mon Sep 17 00:00:00 2001 From: Mercy Ma Date: Tue, 21 Jan 2025 19:09:57 +0800 Subject: [PATCH] Update Resilience4jUtils.java --- .../resilience4j/util/Resilience4jUtils.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/microsphere-resilience4j-commons/src/main/java/io/microsphere/resilience4j/util/Resilience4jUtils.java b/microsphere-resilience4j-commons/src/main/java/io/microsphere/resilience4j/util/Resilience4jUtils.java index f0c5181..44700c9 100644 --- a/microsphere-resilience4j-commons/src/main/java/io/microsphere/resilience4j/util/Resilience4jUtils.java +++ b/microsphere-resilience4j-commons/src/main/java/io/microsphere/resilience4j/util/Resilience4jUtils.java @@ -17,16 +17,13 @@ package io.microsphere.resilience4j.util; import io.github.resilience4j.core.Registry; -import io.microsphere.reflect.MethodUtils; import io.microsphere.resilience4j.common.Resilience4jModule; import io.microsphere.util.BaseUtils; -import java.lang.invoke.MethodHandle; import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; -import static io.microsphere.invoke.MethodHandleUtils.findVirtual; import static io.microsphere.reflect.MethodUtils.findMethod; import static io.microsphere.reflect.MethodUtils.invokeMethod; import static io.microsphere.resilience4j.common.Resilience4jModule.valueOf; @@ -42,19 +39,18 @@ */ public abstract class Resilience4jUtils extends BaseUtils { - private static final Map getEntryMethodsCache; static { Resilience4jModule[] modules = Resilience4jModule.values(); Map methodsCache = new HashMap<>(modules.length); for (Resilience4jModule module : modules) { - initGetEntryMethodHandlesCache(module, methodsCache); + initGetEntryMethodsCache(module, methodsCache); } getEntryMethodsCache = unmodifiableMap(methodsCache); } - private static void initGetEntryMethodHandlesCache(Resilience4jModule module, Map methodsCache) { + private static void initGetEntryMethodsCache(Resilience4jModule module, Map methodsCache) { Class entryClass = module.getEntryClass(); Class configClass = module.getConfigurationClass(); Class registryClass = module.getRegistryClass(); @@ -63,6 +59,10 @@ private static void initGetEntryMethodHandlesCache(Resilience4jModule module, Ma methodsCache.put(module, method); } + public static E getEntry(Registry registry, String name) { + return getEntry(registry, name, registry.getDefaultConfig()); + } + public static E getEntry(Registry registry, String name, C configuration) { Resilience4jModule module = valueOf(registry.getClass()); Method method = getEntryMethodsCache.get(module);