You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2021/10/29 15:08:56 UTC

[brooklyn-server] branch master updated (6c0da04 -> d06704b)

This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git.


    from 6c0da04  Merge pull request #1268 from jcabrerizo/feature/policy/search-policy-as-type-registry
     new 4364509  Allowing to define the reconfigurable property using a string or boolean - test added
     new 8bb7715  change logic as suggested
     new d06704b  This closes #1269

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/brooklyn/core/objs/BasicSpecParameter.java     |  8 +++++---
 .../brooklyn/core/objs/BasicSpecParameterFromListTest.java    | 11 +++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

[brooklyn-server] 01/03: Allowing to define the reconfigurable property using a string or boolean - test added

Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit 4364509cd48e4fc01c6c1418974260116581c4ac
Author: zan-mateusz <ma...@cloudsoftcorp.com>
AuthorDate: Fri Oct 29 15:24:46 2021 +0100

    Allowing to define the reconfigurable property using a string or boolean - test added
---
 .../org/apache/brooklyn/core/objs/BasicSpecParameter.java     |  6 ++++--
 .../brooklyn/core/objs/BasicSpecParameterFromListTest.java    | 11 +++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java b/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
index 9bdc297..f38a1df 100644
--- a/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
+++ b/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
@@ -52,6 +52,7 @@ import org.apache.brooklyn.util.collections.MutableList;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.collections.MutableSet;
 import org.apache.brooklyn.util.core.flags.BrooklynTypeNameResolution;
+import org.apache.brooklyn.util.core.flags.TypeCoercions;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.apache.brooklyn.util.guava.TypeTokens;
 import org.slf4j.Logger;
@@ -248,7 +249,8 @@ public class BasicSpecParameter<T> implements SpecParameter<T>{
             boolean hasTypeInheritance = inputDef.containsKey("inheritance.type");
             ConfigInheritance typeInheritance = parseInheritance(inputDef.get("inheritance.type"), loader);
 
-            boolean isReconfigurable = inputDef.containsKey("reconfigurable") && inputDef.get("reconfigurable").equals(true);
+            Boolean isReconfigurable = TypeCoercions.coerce(inputDef.get("reconfigurable"), Boolean.class);
+
             if (name == null) {
                 throw new IllegalArgumentException("'name' value missing from input definition " + obj + " but is required. Check for typos.");
             }
@@ -269,7 +271,7 @@ public class BasicSpecParameter<T> implements SpecParameter<T>{
                     .constraint(constraint)
                     .runtimeInheritance(runtimeInheritance)
                     .typeInheritance(typeInheritance)
-                    .reconfigurable(isReconfigurable);
+                    .reconfigurable((isReconfigurable!=null) ? isReconfigurable : false);
 
             if (TypeTokens.equalsRaw(PortRange.class, typeToken)) {
                 sensorType = new PortAttributeSensorAndConfigKey(builder);
diff --git a/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromListTest.java b/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromListTest.java
index 1a846bb..fc6da56 100644
--- a/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromListTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/objs/BasicSpecParameterFromListTest.java
@@ -198,6 +198,17 @@ public class BasicSpecParameterFromListTest extends BrooklynMgmtUnitTestSupport
         assertFalse(type.isReconfigurable());
     }
 
+    @Test
+    public void testReconfigurableCoercedFromString() {
+        String name = "reconfigurable coerced from string";
+        SpecParameter<?> input = parseSpecParameterDefinition(ImmutableMap.of(
+                "name", name,
+                "reconfigurable","true"));
+
+        ConfigKey<?> type = input.getConfigKey();
+        assertTrue(type.isReconfigurable());
+    }
+
     private SpecParameter<?> parseSpecParameterDefinition(Object def) {
         BrooklynClassLoadingContext loader = JavaBrooklynClassLoadingContext.create(mgmt);
         List<SpecParameter<?>> inputs = BasicSpecParameter.parseParameterDefinitionList(ImmutableList.of(def), null, loader);

[brooklyn-server] 03/03: This closes #1269

Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit d06704b1745aeb7a982d543adc2039221dd6396b
Merge: 6c0da04 8bb7715
Author: Alex Heneveld <al...@cloudsoftcorp.com>
AuthorDate: Fri Oct 29 16:08:51 2021 +0100

    This closes #1269

 .../org/apache/brooklyn/core/objs/BasicSpecParameter.java     |  8 +++++---
 .../brooklyn/core/objs/BasicSpecParameterFromListTest.java    | 11 +++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

[brooklyn-server] 02/03: change logic as suggested

Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit 8bb771574951522664b527d610765738c4d9bea7
Author: zan-mateusz <ma...@cloudsoftcorp.com>
AuthorDate: Fri Oct 29 15:49:21 2021 +0100

    change logic as suggested
---
 .../main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java b/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
index f38a1df..3206be7 100644
--- a/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
+++ b/core/src/main/java/org/apache/brooklyn/core/objs/BasicSpecParameter.java
@@ -270,8 +270,8 @@ public class BasicSpecParameter<T> implements SpecParameter<T>{
                     .defaultValue(immutableDefaultValue)
                     .constraint(constraint)
                     .runtimeInheritance(runtimeInheritance)
-                    .typeInheritance(typeInheritance)
-                    .reconfigurable((isReconfigurable!=null) ? isReconfigurable : false);
+                    .typeInheritance(typeInheritance);
+            if (isReconfigurable!=null) builder.reconfigurable(isReconfigurable);
 
             if (TypeTokens.equalsRaw(PortRange.class, typeToken)) {
                 sensorType = new PortAttributeSensorAndConfigKey(builder);