陈景阳 4 years ago
parent fefa3469fd
commit 78f81416c3
  1. 8
      src/main/java/org/anyin/gitee/shiro/extension/DefaultExtensionHandlerFactoryImpl.java
  2. 13
      src/main/java/org/anyin/gitee/shiro/extension/IExtensionHandlerFactory.java

@ -31,10 +31,10 @@ public class DefaultExtensionHandlerFactoryImpl implements IExtensionHandlerFact
ExtensionCacheKey<Y> cacheKey = new ExtensionCacheKey(extension, type);
IExtensionHandler result = this.serviceCache.get(cacheKey);
if (result == null) {
List<IExtensionHandler> payPlatformAbles = serviceListCache.getOrDefault(extension, Collections.synchronizedList(Collections.emptyList()));
for (IExtensionHandler payPlatformAble : payPlatformAbles) {
if (type.isAssignableFrom(payPlatformAble.getClass())) {
result = payPlatformAble;
List<IExtensionHandler> extensionHandlers = serviceListCache.getOrDefault(extension, Collections.synchronizedList(Collections.emptyList()));
for (IExtensionHandler extensionHandler : extensionHandlers) {
if (type.isAssignableFrom(extensionHandler.getClass())) {
result = extensionHandler;
serviceCache.put(cacheKey, result);
break;
}

@ -1,8 +1,19 @@
package org.anyin.gitee.shiro.extension;
public interface IExtensionHandlerFactory {
/**
* 添加扩展处理器
* @param extensionHandler 处理器
* @param <Y> 扩展点
*/
<Y extends Enum<Y>>void addExtensionHandler(IExtensionHandler<Y> extensionHandler);
/**
* 获取扩展点处理器
* @param extension 扩展点
* @param type 处理器类型
* @param <T> 扩展处理器
* @param <Y> 扩展点
*/
<T extends IExtensionHandler<Y>,Y extends Enum<Y>> T getExtensionHandler(Y extension, Class<T> type);
}

Loading…
Cancel
Save