1:这个slot的作用是什么?
个人觉得 这个 NodeSelectorSlot 是用来后续扩展的: 如果是分布式的时候, 可以选择不同的节点,来处理。(纯猜测!)
public void entry(Context context, ResourceWrapper resourceWrapper, Object obj, int count, boolean prioritized, Object... args)
throws Throwable {
//这个map一开始是没值的。是属于NodeSelectorSlot 中的属性,与 ContextUtil中的 contextNameNodeMap属性 不一样。
DefaultNode node = map.get(context.getName());
if (node == null) {
synchronized (this) {
node = map.get(context.getName());
if (node == null) {
//创建一个默认的节点。
node = new DefaultNode(resourceWrapper, null);
HashMap<String, DefaultNode> cacheMap = new HashMap<String, DefaultNode>(map.size());
cacheMap.putAll(map);
cacheMap.put(context.getName(), node);
map = cacheMap;
// Build invocation tree
//添加到最后一个节点中
((DefaultNode) context.getLastNode()).addChild(node);
}
}
}
//设置到上下文中
context.setCurNode(node);
//进入下一个Slot
fireEntry(context, resourceWrapper, node, count, prioritized, args);
}