Commit e3be4f1e authored by 杨锐's avatar 杨锐

策略工厂bug修复。

parent 71d0292b
package cn.quantgroup.xyqb.controller.middleoffice.common;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
import cn.quantgroup.xyqb.util.ApplicationContextHolder;
import java.util.HashMap;
import java.util.Map;
......@@ -12,13 +11,11 @@ public class VerifyStrategyFactory {
static {
//cache
WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
Map<String, IVerifyStrategy> beansOfType = context.getBeansOfType(IVerifyStrategy.class);
Map<String, IVerifyStrategy> beansOfType = ApplicationContextHolder.getBeansOfType(IVerifyStrategy.class);
beansOfType.values().forEach(strategy -> strategiesMap.put(strategy.strategyName(), strategy));
}
public static IVerifyStrategy get(VerifyTypeEnum verifyTypeEnum) {
return strategiesMap.get(verifyTypeEnum);
}
}
......@@ -7,6 +7,8 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* Created by Miraculous on 15/7/12.
*/
......@@ -120,4 +122,7 @@ public class ApplicationContextHolder implements ApplicationContextAware {
return applicationContext.getAliases(name);
}
public static <T> Map<String, T> getBeansOfType(Class<T> requiredType) throws BeansException {
return applicationContext.getBeansOfType(requiredType);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment