Source:
private EntitySpec<?> resolveSpec( BrooklynComponentTemplateResolver entityResolver, Set<String> encounteredCatalogTypes) { ManagementContext mgmt = entityResolver.loader.getManagementContext(); String brooklynType = entityResolver.getBrooklynType(); CatalogItem<Entity, EntitySpec<?>> item = entityResolver.getCatalogItem(); boolean firstOccurrence = encounteredCatalogTypes.add(brooklynType); boolean recursiveButTryJava = !firstOccurrence; if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+brooklynType+"; item="+item+"; loader="+entityResolver.loader+"; encounteredCatalogTypes="+encounteredCatalogTypes); EntitySpec<?> spec = null; if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(Urls.getProtocol(brooklynType))) { spec = tryResolveYamlURLReferenceSpec(brooklynType, entityResolver.loader, encounteredCatalogTypes); if (spec != null) { entityResolver.populateSpec(spec); } } if (spec == null) { if (item == null || item.getJavaType() != null || entityResolver.isJavaTypePrefix()) { spec = entityResolver.resolveSpec(); } else if (recursiveButTryJava) { if (entityResolver.tryLoadEntityClass().isAbsent()) { throw new IllegalStateException("Recursive reference to " + brooklynType + " (and cannot be resolved as a Java type)"); } spec = entityResolver.resolveSpec(); } else { spec = resolveCatalogYamlReferenceSpec(mgmt, item, encounteredCatalogTypes); entityResolver.populateSpec(spec); } } BrooklynClassLoadingContext newLoader = entityResolver.loader; buildChildrenEntitySpecs(newLoader, spec, entityResolver.getChildren(entityResolver.attrs.getAllConfig()), encounteredCatalogTypes); return spec; }

Target:
private EntitySpec<?> resolveSpec( BrooklynComponentTemplateResolver entityResolver, Set<String> encounteredCatalogTypes) { ManagementContext mgmt = entityResolver.loader.getManagementContext(); String brooklynType = entityResolver.getBrooklynType(); CatalogItem<Entity, EntitySpec<?>> item = entityResolver.getCatalogItem(); boolean firstOccurrence = encounteredCatalogTypes.add(brooklynType); boolean recursiveButTryJava = !firstOccurrence; if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+brooklynType+"; item="+item+"; loader="+entityResolver.loader+"; encounteredCatalogTypes="+encounteredCatalogTypes); EntitySpec<?> spec = null; String protocol = Urls.getProtocol(brooklynType); if (protocol != null) { if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(protocol)) { spec = tryResolveYamlURLReferenceSpec(brooklynType, entityResolver.loader, encounteredCatalogTypes); if (spec != null) { entityResolver.populateSpec(spec); } } else { log.warn("The reference " + brooklynType + " looks like an URL but the protocol " + protocol + " isn't white listed (" + BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST + "). " + "Will try to load it as catalog item or java type."); } } if (spec == null) { if (item == null || item.getJavaType() != null || entityResolver.isJavaTypePrefix()) { spec = entityResolver.resolveSpec(); } else if (recursiveButTryJava) { if (entityResolver.tryLoadEntityClass().isAbsent()) { throw new IllegalStateException("Recursive reference to " + brooklynType + " (and cannot be resolved as a Java type)"); } spec = entityResolver.resolveSpec(); } else { spec = resolveCatalogYamlReferenceSpec(mgmt, item, encounteredCatalogTypes); entityResolver.populateSpec(spec); } } BrooklynClassLoadingContext newLoader = entityResolver.loader; buildChildrenEntitySpecs(newLoader, spec, entityResolver.getChildren(entityResolver.attrs.getAllConfig()), encounteredCatalogTypes); return spec; }