brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neykov <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #781: Support DSL in template options
Date Fri, 28 Jul 2017 08:46:26 GMT
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/781#discussion_r130041426
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/templates/customize/TemplateOptionsOption.java
---
    @@ -39,8 +45,17 @@ public void apply(TemplateOptions options, ConfigBag config, Object
v) {
     
             Class<? extends TemplateOptions> clazz = options.getClass();
             for (final Map.Entry<String, Object> option : optionsMap.entrySet()) {
    -            if (option.getValue() != null) {
    -                Maybe<?> result = MethodCoercions.tryFindAndInvokeBestMatchingMethod(options,
option.getKey(), option.getValue());
    +            Object optionValue = option.getValue();
    +            if (optionValue != null) {
    +
    +                if (optionValue instanceof TaskFactory<?>) {
    +                    final TaskAdaptable<?> taskA = ((TaskFactory<?>) optionValue).newTask();
    +                    optionValue = getValueFromTask(taskA.asTask());
    +                } else if (optionValue instanceof TaskAdaptable<?>) {
    +                    optionValue = getValueFromTask(((TaskAdaptable<?>) optionValue).asTask());
    +                }
    +
    +                Maybe<?> result = MethodCoercions.tryFindAndInvokeBestMatchingMethod(options,
option.getKey(), optionValue);
    --- End diff --
    
    Don't think you can use `null` here. Seems the thread context is something used around
immediate values only. cc @ahgittin.
    
    Looking at the code the canonical usage is with: `((EntityInternal)BrooklynTaskTags.getTargetOrContextEntity(Tasks.current())).getExecutionContext()`.


---
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