brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [3/6] brooklyn-server git commit: BROOKLYN-249: fix location rebind for external config
Date Wed, 06 Apr 2016 11:23:27 GMT
BROOKLYN-249: fix location rebind for external config

Fixes it only for ConfigKeys, rather than for fields that use
`@SetFromFlag`. The latter can be addressed in a separate pull request.

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/148e6d78
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/148e6d78
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/148e6d78

Branch: refs/heads/0.9.0
Commit: 148e6d78a07e2001eddf48d0bf610b598cff12c6
Parents: 67bbb0e
Author: Aled Sage <aled.sage@gmail.com>
Authored: Tue Apr 5 18:00:21 2016 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Wed Apr 6 11:25:31 2016 +0100

----------------------------------------------------------------------
 .../mgmt/rebind/BasicLocationRebindSupport.java     | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/148e6d78/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicLocationRebindSupport.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicLocationRebindSupport.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicLocationRebindSupport.java
index b789501..0f10672 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicLocationRebindSupport.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/BasicLocationRebindSupport.java
@@ -29,11 +29,11 @@ import org.apache.brooklyn.api.mgmt.rebind.mementos.LocationMemento;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.location.AbstractLocation;
 import org.apache.brooklyn.core.mgmt.rebind.dto.MementosGenerators;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.core.flags.FlagUtils;
 import org.apache.brooklyn.util.core.flags.TypeCoercions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Sets;
 
@@ -64,6 +64,7 @@ public class BasicLocationRebindSupport extends AbstractBrooklynObjectRebindSupp
         return memento;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     protected void addConfig(RebindContext rebindContext, LocationMemento memento) {
         // FIXME Treat config like we do for entities; this code will disappear when locations
become entities.
@@ -89,14 +90,15 @@ public class BasicLocationRebindSupport extends AbstractBrooklynObjectRebindSupp
                 // And use magic of setFieldFromFlag's magic to either set config or field
as appropriate.
                 if (ConfigKey.class.isAssignableFrom(fieldType)) {
                     ConfigKey<?> configKey = (ConfigKey<?>) FlagUtils.getField(location,
field);
-                    value = TypeCoercions.coerce(entry.getValue(), configKey.getTypeToken());
+                    location.config().set((ConfigKey<Object>)configKey, entry.getValue());
                 } else {
                     value = TypeCoercions.coerce(entry.getValue(), fieldType);
+                    if (value != null) {
+                        location.config().addToLocalBag(MutableMap.of(flagName, value));
+                        FlagUtils.setFieldFromFlag(location, flagName, value);
+                    }
                 }
-                if (value != null) {
-                    location.config().addToLocalBag(MutableMap.of(flagName, value));
-                    FlagUtils.setFieldFromFlag(location, flagName, value);
-                }
+                
             } catch (NoSuchElementException e) {
                 // FIXME How to do findFieldForFlag without throwing exception if it's not
there?
             }


Mime
View raw message