brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drigod...@apache.org
Subject [1/3] brooklyn-server git commit: Fix BrooklynYamlTypeInstantiatorTest.testLoadPolicySpecWithBrooklynConfig
Date Mon, 12 Jun 2017 14:13:45 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master 68babc6f2 -> ed25e5e39


Fix BrooklynYamlTypeInstantiatorTest.testLoadPolicySpecWithBrooklynConfig

Previously it relied on ServiceRestarter to have a constructor that 
took a Map or ConfigBag. Now we check if the type implements
Configurable, to handle no-arg constructors as well.

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

Branch: refs/heads/master
Commit: 260c80f95e6a62c5526d81b1f0db0cc3352d3434
Parents: 0fac0d6
Author: Aled Sage <aled.sage@gmail.com>
Authored: Sun Jun 11 15:52:29 2017 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Sun Jun 11 16:06:46 2017 +0100

----------------------------------------------------------------------
 .../brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java | 9 +++++++++
 1 file changed, 9 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/260c80f9/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
----------------------------------------------------------------------
diff --git a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
index 5852139..aa1dfe9 100644
--- a/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
+++ b/camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
@@ -24,7 +24,9 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import org.apache.brooklyn.api.mgmt.classloading.BrooklynClassLoadingContext;
+import org.apache.brooklyn.api.objs.Configurable;
 import org.apache.brooklyn.camp.brooklyn.BrooklynCampReservedKeys;
+import org.apache.brooklyn.core.objs.BrooklynObjectInternal.ConfigurationSupportInternal;
 import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.core.config.ConfigBag;
 import org.apache.brooklyn.util.exceptions.Exceptions;
@@ -141,6 +143,13 @@ public abstract class BrooklynYamlTypeInstantiator {
                 result = Reflections.invokeConstructorFromArgs(type);
                 if (result.isPresent()) 
                     return result.get();
+            } else if (Configurable.class.isAssignableFrom(type)) {
+                result = Reflections.invokeConstructorFromArgs(type);
+                if (result.isPresent()) {
+                    ConfigurationSupportInternal configSupport = (ConfigurationSupportInternal)
((Configurable)result.get()).config();
+                    configSupport.putAll(cfg);
+                    return result.get();
+                }
             }
             
             throw new IllegalStateException("No known mechanism for constructing type "+type+"
in "+factory.contextForLogging);


Mime
View raw message