brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/4] incubator-brooklyn git commit: Introduce constants for commonly used strings
Date Fri, 24 Jul 2015 05:07:20 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master d01554af2 -> bfcb8c35e


Introduce constants for commonly used strings


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

Branch: refs/heads/master
Commit: ea763893004159942ce2089f7f60083177b288c5
Parents: d7ac3ac
Author: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Authored: Thu Jul 16 14:13:39 2015 +0300
Committer: Svetoslav Neykov <svetoslav.neykov@cloudsoftcorp.com>
Committed: Thu Jul 16 14:13:55 2015 +0300

----------------------------------------------------------------------
 .../camp/brooklyn/BrooklynCampReservedKeys.java | 29 ++++++++++++++++++++
 .../BrooklynComponentTemplateResolver.java      |  5 ++--
 .../BrooklynEntityDecorationResolver.java       |  7 +++--
 .../creation/BrooklynYamlTypeInstantiator.java  |  3 +-
 .../spi/dsl/methods/BrooklynDslCommon.java      |  3 +-
 .../camp/brooklyn/JavaWebAppsMatchingTest.java  |  6 ++--
 6 files changed, 43 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ea763893/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampReservedKeys.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampReservedKeys.java
b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampReservedKeys.java
new file mode 100644
index 0000000..b81e223
--- /dev/null
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampReservedKeys.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package io.brooklyn.camp.brooklyn;
+
+public interface BrooklynCampReservedKeys {
+    public static final String BROOKLYN_CONFIG = "brooklyn.config";
+    public static final String BROOKLYN_FLAGS = "brooklyn.flags";
+    public static final String BROOKLYN_POLICIES = "brooklyn.policies";
+    public static final String BROOKLYN_ENRICHERS = "brooklyn.enrichers";
+    public static final String BROOKLYN_CHILDREN = "brooklyn.children";
+    public static final String BROOKLYN_INITIALIZERS = "brooklyn.initializers";
+    public static final String BROOKLYN_CATALOG = "brooklyn.catalog";
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ea763893/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
index c157e93..e26240f 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java
@@ -19,6 +19,7 @@
 package io.brooklyn.camp.brooklyn.spi.creation;
 
 import io.brooklyn.camp.brooklyn.BrooklynCampConstants;
+import io.brooklyn.camp.brooklyn.BrooklynCampReservedKeys;
 import io.brooklyn.camp.brooklyn.spi.creation.service.BrooklynServiceTypeResolver;
 import io.brooklyn.camp.brooklyn.spi.creation.service.ServiceTypeResolver;
 import io.brooklyn.camp.spi.AbstractResource;
@@ -293,7 +294,7 @@ public class BrooklynComponentTemplateResolver {
         if (planId==null)
             planId = (String) attrs.getStringKey(BrooklynCampConstants.PLAN_ID_FLAG);
 
-        Object childrenObj = attrs.getStringKey("brooklyn.children");
+        Object childrenObj = attrs.getStringKey(BrooklynCampReservedKeys.BROOKLYN_CHILDREN);
         if (childrenObj != null) {
             // Creating a new set of encounteredCatalogTypes means that this won't check
things recursively;
             // but we are looking at children so we probably *should* be resetting the recursive
list we've looked at;
@@ -462,7 +463,7 @@ public class BrooklynComponentTemplateResolver {
     @SuppressWarnings("unchecked")
     protected List<Map<String, Object>> getChildren(Map<String, Object>
attrs) {
         if (attrs==null) return null;
-        return (List<Map<String, Object>>) attrs.get("brooklyn.children");
+        return (List<Map<String, Object>>) attrs.get(BrooklynCampReservedKeys.BROOKLYN_CHILDREN);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ea763893/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityDecorationResolver.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityDecorationResolver.java
b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityDecorationResolver.java
index ce814b4..f0fd10f 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityDecorationResolver.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityDecorationResolver.java
@@ -18,6 +18,7 @@
  */
 package io.brooklyn.camp.brooklyn.spi.creation;
 
+import io.brooklyn.camp.brooklyn.BrooklynCampReservedKeys;
 import io.brooklyn.camp.brooklyn.spi.creation.BrooklynYamlTypeInstantiator.InstantiatorFromKey;
 
 import java.util.List;
@@ -98,7 +99,7 @@ public abstract class BrooklynEntityDecorationResolver<DT> {
         
         @Override
         protected Object getDecorationAttributeJsonValue(ConfigBag attrs) {
-            return attrs.getStringKey("brooklyn.policies");
+            return attrs.getStringKey(BrooklynCampReservedKeys.BROOKLYN_POLICIES);
         }
 
         @Override
@@ -144,7 +145,7 @@ public abstract class BrooklynEntityDecorationResolver<DT> {
         
         @Override
         protected Object getDecorationAttributeJsonValue(ConfigBag attrs) {
-            return attrs.getStringKey("brooklyn.enrichers");
+            return attrs.getStringKey(BrooklynCampReservedKeys.BROOKLYN_ENRICHERS);
         }
 
         @Override
@@ -167,7 +168,7 @@ public abstract class BrooklynEntityDecorationResolver<DT> {
         
         @Override
         protected Object getDecorationAttributeJsonValue(ConfigBag attrs) {
-            return attrs.getStringKey("brooklyn.initializers");
+            return attrs.getStringKey(BrooklynCampReservedKeys.BROOKLYN_INITIALIZERS);
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ea763893/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
index c5f3dcb..b78f359 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynYamlTypeInstantiator.java
@@ -32,6 +32,7 @@ import brooklyn.util.config.ConfigBag;
 import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.guava.Maybe;
 import brooklyn.util.javalang.Reflections;
+import io.brooklyn.camp.brooklyn.BrooklynCampReservedKeys;
 
 import com.google.common.annotations.Beta;
 import com.google.common.base.Optional;
@@ -155,7 +156,7 @@ public abstract class BrooklynYamlTypeInstantiator {
         @Nonnull
         public Map<String,?> getConfigMap() {
             MutableMap<String,Object> result = MutableMap.of();
-            Object bc = data.getStringKey("brooklyn.config");
+            Object bc = data.getStringKey(BrooklynCampReservedKeys.BROOKLYN_CONFIG);
             if (bc!=null) {
                 if (bc instanceof Map)
                     result.putAll((Map<? extends String, ?>) bc);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ea763893/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
index f488d61..efcdd49 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/dsl/methods/BrooklynDslCommon.java
@@ -18,6 +18,7 @@
  */
 package io.brooklyn.camp.brooklyn.spi.dsl.methods;
 
+import io.brooklyn.camp.brooklyn.BrooklynCampReservedKeys;
 import io.brooklyn.camp.brooklyn.spi.creation.BrooklynYamlTypeInstantiator;
 import io.brooklyn.camp.brooklyn.spi.creation.EntitySpecConfiguration;
 import io.brooklyn.camp.brooklyn.spi.dsl.BrooklynDslDeferredSupplier;
@@ -144,7 +145,7 @@ public class BrooklynDslCommon {
         ConfigBag config = ConfigBag.newInstance(arguments);
         String typeName = BrooklynYamlTypeInstantiator.InstantiatorFromKey.extractTypeName("object",
config).orNull();
         Map<String,Object> objectFields = (Map<String, Object>) config.getStringKeyMaybe("object.fields").or(MutableMap.of());
-        Map<String,Object> brooklynConfig = (Map<String, Object>) config.getStringKeyMaybe("brooklyn.config").or(MutableMap.of());
+        Map<String,Object> brooklynConfig = (Map<String, Object>) config.getStringKeyMaybe(BrooklynCampReservedKeys.BROOKLYN_CONFIG).or(MutableMap.of());
         try {
             // TODO Should use catalog's classloader, rather than Class.forName; how to get
that? Should we return a future?!
             Class<?> type = Class.forName(typeName);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ea763893/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/JavaWebAppsMatchingTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/JavaWebAppsMatchingTest.java
b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/JavaWebAppsMatchingTest.java
index 28e8ef5..a9ddf63 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/JavaWebAppsMatchingTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/JavaWebAppsMatchingTest.java
@@ -87,7 +87,7 @@ public class JavaWebAppsMatchingTest {
         
         DeploymentPlan plan = platform.pdp().parseDeploymentPlan(input);
         log.info("DP is:\n"+plan.toString());
-        Map<?,?> cfg1 = (Map<?, ?>) plan.getServices().get(0).getCustomAttributes().get("brooklyn.config");
+        Map<?,?> cfg1 = (Map<?, ?>) plan.getServices().get(0).getCustomAttributes().get(BrooklynCampReservedKeys.BROOKLYN_CONFIG);
         Map<?,?> cfg = MutableMap.copyOf(cfg1);
         
         Assert.assertEquals(cfg.remove("literalValue1"), "$brooklyn: is a fun place");
@@ -106,7 +106,7 @@ public class JavaWebAppsMatchingTest {
         Assert.assertEquals(at.getCustomAttributes().get("location"), "localhost");
         
         PlatformComponentTemplate pct = at.getPlatformComponentTemplates().links().iterator().next().resolve();
-        Object cfg2 = pct.getCustomAttributes().get("brooklyn.config");
+        Object cfg2 = pct.getCustomAttributes().get(BrooklynCampReservedKeys.BROOKLYN_CONFIG);
         Assert.assertEquals(cfg2, cfg1);
     }
 
@@ -133,7 +133,7 @@ public class JavaWebAppsMatchingTest {
 
         PlatformComponentTemplate pct2 = pcti.next().resolve(); 
 
-        Map<?,?> config = (Map<?, ?>) pct1.getCustomAttributes().get("brooklyn.config");
+        Map<?,?> config = (Map<?, ?>) pct1.getCustomAttributes().get(BrooklynCampReservedKeys.BROOKLYN_CONFIG);
         Map<?,?> javaSysProps = (Map<?, ?>) config.get("java.sysprops");
         Object dbUrl = javaSysProps.get("brooklyn.example.db.url");
         Assert.assertTrue(dbUrl instanceof DeferredSupplier<?>, "url is: "+dbUrl);


Mime
View raw message