// ����name��broker��ӳ��
Map<String, URIBrokerInfo> brokerInfoMap = createLinkedHashMap();
for (URIBrokerInfo brokerInfo : brokerInfos) {
URIBroker broker = assertNotNull(brokerInfo == null ? null : brokerInfo.broker, "broker");
brokerInfo.name = assertNotNull(trimToNull(brokerInfo.name), "broker ID");
brokerInfo.parentName = trimToNull(brokerInfo.parentName);
assertTrue(!brokerInfoMap.containsKey(brokerInfo.name), "duplicated broker ID: %s", brokerInfo.name);
brokerInfoMap.put(brokerInfo.name, brokerInfo);
brokers.put(brokerInfo.name, broker);
names.add(brokerInfo.name);
if (brokerInfo.exposed) {
exposedNames.add(brokerInfo.name);
}
// ���ö���uri��Ĭ��ֵ������������requestAware������broker�е�Ĭ��ֵ
if (requestAware != null && brokerInfo.parentName == null) {
broker.setRequestAwareDefault(requestAware);
}
// ���ö���uri��Ĭ��ֵ������������defaultCharset������Ĭ�ϵ�broker charset��
if (defaultCharset != null && brokerInfo.parentName == null && broker.getCharset() == null) {
broker.setCharset(defaultCharset);
}
broker.setRequest(request);
}
brokerInfos = null;
// import uris
if (!isEmptyArray(importUris)) {
for (URIBrokerService importUriBrokerService : importUris) {
Set<String> exposedImportNames = createHashSet(importUriBrokerService.getExposedNames());
for (String name : importUriBrokerService.getNames()) {
// ����ǰ�ļ��е�uri����parent�е�ͬ��uri��
if (brokers.containsKey(name)) {
continue;
}
URIBroker uri = importUriBrokerService.getURIBroker(name);
if (uri.isAutoReset() && uri.getParent() != null && !uri.getParent().isAutoReset()) {
uri = uri.getParent();
} else {
uri = uri.fork(false);
}
brokers.put(name, uri);
names.add(name);
if (exposedImportNames.contains(name)) {
exposedNames.add(name);
}
}
}
}
// ����parent brokers��ȷ��parent broker��������Ҳ�Ǹ����ͬ�࣬ͬʱȷ��û�еݹ�����
for (Map.Entry<String, URIBrokerInfo> entry : brokerInfoMap.entrySet()) {
String name = entry.getKey();
URIBrokerInfo brokerInfo = entry.getValue();
String parentName = brokerInfo.parentName;
// ���̳�����ȷ��û�еݹ�
checkCyclic(brokerInfoMap, name, parentName);
if (parentName != null) {
URIBroker parentBroker = assertNotNull(brokers.get(parentName),
"parent \"%s\" not found for broker \"%s\"", parentName, brokerInfo.name);
URIBroker thisBroker = brokerInfo.broker;
thisBroker.setParent(parentBroker);
}
}
// �ݹ鸴��parent�е���Ϣ
for (URIBroker broker : brokers.values()) {