brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbouron <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Adds support for interfaces tag o...
Date Thu, 19 Nov 2015 09:39:22 GMT
Github user tbouron commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/1039#discussion_r45318592
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
---
    @@ -558,15 +561,34 @@ private void collectCatalogItems(String sourceYaml, Map<?,?>
itemMetadata, List<
                 throw new IllegalStateException("Could not resolve plan once id and itemType
are known (recursive reference?): "+sourceYaml);
             }
             String sourcePlanYaml = planInterpreter.getPlanYaml();
    -        
    -        CatalogItemDtoAbstract<?, ?> dto = createItemBuilder(itemType, symbolicName,
version)
    +
    +        CatalogItemBuilder itemBuilder = createItemBuilder(itemType, symbolicName, version)
                 .libraries(libraryBundles)
                 .displayName(displayName)
                 .description(description)
                 .deprecated(catalogDeprecated)
                 .iconUrl(catalogIconUrl)
    -            .plan(sourcePlanYaml)
    -            .build();
    +            .plan(sourcePlanYaml);
    +        if (itemType.equals(CatalogItemType.ENTITY) || itemType.equals(CatalogItemType.TEMPLATE))
{
    +            String stringServiceType = getFirstAs(itemAsMap, String.class, "type").orNull();
    +            // This is not a single item but a services based YAML
    +            if (stringServiceType == null) {
    +                final List<Map<?, ?>> services = getFirstAs(itemAsMap, List.class,
"services").orNull();
    +                if (services.isEmpty()) {
    +                    throw new IllegalStateException("Services are empty: " + sourceYaml);
    +                }
    +                stringServiceType = services.get(0).get("type").toString();
    +            }
    +            Class<?> serviceType = JavaBrooklynClassLoadingContext.create(mgmt).tryLoadClass(stringServiceType).orNull();
    +            if (serviceType == null) {
    +                final CatalogItem<?, ?> relatedCatalogItem = getCatalogItem(stringServiceType,
"");
    +                if (relatedCatalogItem != null) {
    +                    serviceType = JavaBrooklynClassLoadingContext.create(mgmt).tryLoadClass(relatedCatalogItem.getJavaType()).orNull();
    +                }
    +            }
    +            itemBuilder.tag(BrooklynTags.newInterfacesTag(ClassUtils.getAllInterfaces(serviceType)));
    --- End diff --
    
    [The code seems to be the same](https://git-wip-us.apache.org/repos/asf?p=commons-lang.git;a=blob;f=src/main/java/org/apache/commons/lang3/ClassUtils.java;h=0a7480ff8d991e555be679f86377dc19d3eb64d7;hb=HEAD#l433)
as `Reflections.getAllInterfaces(Class<?>)`. Although, the `Reflections` class says
in its headers:
    >  Reflection utilities ("borrowed" from cloudsoft monterey).
    
    So I would still use `ClassUtils`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message