in uimafit-core/src/main/java/org/apache/uima/fit/factory/ExternalResourceFactory.java [1151:1192]
private static void bindNestedResources(ExternalResourceDescription aRes,
Map<String, ExternalResourceBinding> aBindings,
Map<String, ExternalResourceDescription> aResources) {
// Handle nested resources
if (aRes instanceof ExtendedExternalResourceDescription_impl) {
ExtendedExternalResourceDescription_impl extRes = (ExtendedExternalResourceDescription_impl) aRes;
// Tell the external resource its name. This is needed in order to find the resources
// bound to this resource later on. Set only if the resource supports this parameter.
// Mind that supporting this parameter is mandatory for resource implementing
// ExternalResourceAware.
if (canParameterBeSet(extRes.getResourceSpecifier(), PARAM_RESOURCE_NAME)) {
ConfigurationParameterFactory.setParameter(extRes.getResourceSpecifier(),
PARAM_RESOURCE_NAME, aRes.getName());
}
// Create a map of all resources
Map<String, ExternalResourceDescription> res = new HashMap<String, ExternalResourceDescription>();
for (ExternalResourceDescription r : extRes.getExternalResources()) {
res.put(r.getName(), r);
}
// Bind nested resources
for (ExternalResourceBinding b : extRes.getExternalResourceBindings()) {
// Avoid re-prefixing the resource name
String key = b.getKey();
if (!key.startsWith(aRes.getName() + PREFIX_SEPARATOR)) {
key = aRes.getName() + PREFIX_SEPARATOR + b.getKey();
}
// Avoid unnecessary binding and an infinite loop when a resource binds to itself
if (!aBindings.containsKey(key)) {
// Mark the current binding as processed so we do not recurse
aBindings.put(key, b);
ExternalResourceDescription nestedRes = res.get(b.getResourceName());
aResources.put(nestedRes.getName(), nestedRes);
bindNestedResources(nestedRes, aBindings, aResources);
// Set the proper key on the binding.
b.setKey(key);
}
}
}
}