工厂模式
工厂模式
定义工厂类,及工厂方法,获取工厂里面的数据
@Service
@Order
public class RuleFactory {
private static final Logger logger = LoggerFactory.getLogger(RuleFactory.class);
/**
* 本地规则缓存
* ruleKey :rule上下文
*/
private ConcurrentMap<String, RuleContext> ruleContextCache = new ConcurrentHashMap<>();
public RuleContext getRuleContext(Rule rule, String debugIp) {
return ruleContextCache.get(ruleKey);
}
}
原创:做时间的朋友