private final filteringwebhandler webhandler;
private final routelocator routelocator;
//獲取處理器
@override
protected mono<?> gethandlerinternal(serverwebexchange exchange)
//儲存匹配到的路由資訊,並轉換返回
exchange.getattributes().put(gateway_route_attr, r);
return mono.just(webhandler);
}).switchifempty(mono.empty().then(mono.fromrunnable(() ->
})));
} protected monolookuproute(serverwebexchange exchange) )
// .defaultifempty() put a static route not found
// or .switchifempty()
// .switchifempty(mono.empty().log("noroute"))
.next()
//todo: error handling
.map(route ->
validateroute(route, exchange);
return route;
});/* todo: trace logging
if (logger.istraceenabled()) */ }
路由判定工廠,主要通過相應工廠處理出相應的filter
abstractroutepredicatefactory
路由定義器
routedefinitionroutelocator
protected final log logger = logfactory.getlog(getclass());
private final routedefinitionlocator routedefinitionlocator;
private final mappredicates = new linkedhashmap<>();
private final mapgatewayfilte***ctories = new hashmap<>();
private final gatewayproperties gatewayproperties;
private final spelexpressionparser parser = new spelexpressionparser();
private beanfactory beanfactory;
public routedefinitionroutelocator(routedefinitionlocator routedefinitionlocator,
listpredicates,
listgatewayfilte***ctories,
gatewayproperties gatewayproperties)
@autowired
private validator validator;
@override
public void setbeanfactory(beanfactory beanfactory) throws bean***ception
@override
this.publisher = publisher;
} //初始化判定工廠
private void initfactories(listpredicates)
this.predicates.put(key, factory);
if (logger.isinfoenabled())
});} @override
public fluxgetroutes()
return route;
});/* todo: trace logging
if (logger.istraceenabled()) */
} //將路由資訊定義轉換成路由資訊
private route converttoroute(routedefinition routedefinition)
//載入過濾器
@suppresswarnings("unchecked")
private listloadgatewayfilters(string id, listfilterdefinitions)
mapargs = definition.getargs();
if (logger.isdebugenabled())
mapproperties = factory.shortcuttype().normalize(args, factory, this.parser, this.beanfactory);
object configuration = factory.newconfig();
configurationutils.bind(configuration, properties,
factory.shortcutfieldprefix(), definition.getname(), validator);
if (this.publisher != null)
return gatewayfilter;
}).collect(collectors.tolist());
arraylistordered = new arraylist<>(filters.size());
for (int i = 0; i < filters.size(); i++)
else
} return ordered;
} private listgetfilters(routedefinition routedefinition)
if (!routedefinition.getfilters().isempty())
annotationawareordercomparator.sort(filters);
return filters;
} private predicatecombinepredicates(routedefinition routedefinition)
return predicate;
} @suppresswarnings("unchecked")
private predicatelookup(routedefinition route, predicatedefinition predicate)
mapargs = predicate.getargs();
if (logger.isdebugenabled())
mapproperties = factory.shortcuttype().normalize(args, factory, this.parser, this.beanfactory);
object config = factory.newconfig();
configurationutils.bind(config, properties,
factory.shortcutfieldprefix(), predicate.getname(), validator);
if (this.publisher != null) }}
《原始碼閱讀》原始碼閱讀技巧,原始碼閱讀工具
檢視某個類的完整繼承關係 選中類的名稱,然後按f4 quick type hierarchy quick type hierarchy可以顯示出類的繼承結構,包括它的父類和子類 supertype hierarchy supertype hierarchy可以顯示出類的繼承和實現結構,包括它的父類和...
Cartographer原始碼篇 原始碼分析 1
在安裝編譯cartographer 1.0.0的時候,我們可以看到 主要包括cartorgarpher ros cartographer ceres sover三個部分。其中,ceres solver用於非線性優化,求解最小二乘問題 cartographer ros為ros平台的封裝,獲取感測器資料...
python原始碼剖析 Python原始碼剖析
第頁共 頁python 原始碼剖析 物件機制 1.物件 在python 的世界中,一切都是物件,乙個整數是乙個物件,乙個字串也是 乙個物件,更為奇妙的是,型別也是乙個物件,整數型別是乙個物件,字串類 型也是乙個物件。從 年guido 在那個聖誕節揭開 python 世界的大幕開始,一直到現在,pyt...