You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2014/07/18 12:00:37 UTC

[01/10] git commit: AppOrSpec not relevant any more, remove.

Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master c3f0455c6 -> bf71719c8


AppOrSpec not relevant any more, remove.

The code uses only the spec part.


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

Branch: refs/heads/master
Commit: d5a249fe1875dcfb71b041761791a3b44069cd91
Parents: 896d4d0
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Jul 16 11:04:15 2014 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Wed Jul 16 13:20:20 2014 +0300

----------------------------------------------------------------------
 .../BrooklynAssemblyTemplateInstantiator.java   | 47 ++------------------
 1 file changed, 4 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5a249fe/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
index 1921fb1..7a0ab81 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
@@ -78,32 +78,21 @@ public class BrooklynAssemblyTemplateInstantiator implements AssemblyTemplateSpe
         return platform.assemblies().get(app.getApplicationId());
     }
 
-    public EntitySpec<?> createSpec(AssemblyTemplate template, CampPlatform platform) {
-        return createAppOrSpec(template, platform, true).getSpec();
-    }
-
     // note: based on BrooklynRestResourceUtils, but modified to not allow child entities (yet)
     // (will want to revise that when building up from a non-brooklyn template)
     public Application create(AssemblyTemplate template, CampPlatform platform) {
         ManagementContext mgmt = getBrooklynManagementContext(platform);
         
-        AppOrSpec appOrSpec = createAppOrSpec(template, platform, false);
-        
-        if (appOrSpec.hasApp())
-            return appOrSpec.getApp();
-        if (!appOrSpec.hasSpec())
-            throw new IllegalStateException("No spec could be produced from "+template);
-        
-        EntitySpec<? extends Application> spec = appOrSpec.getSpec();
+        EntitySpec<? extends Application> spec = createSpec(template, platform);
         
-        Application instance = (Application) mgmt.getEntityManager().createEntity(spec);
+        Application instance = mgmt.getEntityManager().createEntity(spec);
         log.info("CAMP placing '{}' under management", instance);
         Entities.startManagement(instance, mgmt);
 
         return instance;
     }
     
-    protected AppOrSpec createAppOrSpec(AssemblyTemplate template, CampPlatform platform, boolean requireSpec) {
+    public EntitySpec<? extends Application> createSpec(AssemblyTemplate template, CampPlatform platform) {
         log.debug("CAMP creating application instance for {} ({})", template.getId(), template);
         
         ManagementContext mgmt = getBrooklynManagementContext(platform);
@@ -116,35 +105,7 @@ public class BrooklynAssemblyTemplateInstantiator implements AssemblyTemplateSpe
         } else {
             loader = JavaBrooklynClassLoadingContext.newDefault(mgmt);
         }
-        return new AppOrSpec(createApplicationFromCampTemplate(template, platform, loader));
-    }
-    
-    private static class AppOrSpec {
-        private final Application app;
-        private final EntitySpec<? extends Application> spec;
-        
-        public AppOrSpec(Application app) {
-            this.app = app;
-            this.spec = null;
-        }
-
-        public AppOrSpec(EntitySpec<? extends Application> spec) {
-            this.app = null;
-            this.spec = spec;
-        }
-
-        public boolean hasApp() {
-            return app!=null;
-        }
-        public boolean hasSpec() {
-            return spec!=null;
-        }
-        public Application getApp() {
-            return app;
-        }
-        public EntitySpec<? extends Application> getSpec() {
-            return spec;
-        }
+        return createApplicationFromCampTemplate(template, platform, loader);
     }
     
     private ManagementContext getBrooklynManagementContext(CampPlatform platform) {


[03/10] git commit: Load URL referenced YAMLs.

Posted by al...@apache.org.
Load URL referenced YAMLs.

Allow URL references to YAML files in addition to catalog IDs and java types.
Currently limited to services (PlatformComponentTemplate level).

In the case of more than one service in the referenced plan just use the wrapped app as a child.
The template referencing the yaml will override the name, IDs of the child. Locations, policies,
effectors, ect. will be appended to the child's config. Do the same for catalog item references.


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

Branch: refs/heads/master
Commit: 201717a367a501a5ee174656780a2e3555f04edd
Parents: b982e6f
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Jul 16 11:55:40 2014 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Wed Jul 16 13:20:22 2014 +0300

----------------------------------------------------------------------
 .../camp/brooklyn/BrooklynCampConstants.java    |   5 +
 .../BrooklynAssemblyTemplateInstantiator.java   |  72 +++++++++--
 .../spi/creation/BrooklynEntityMatcher.java     |  21 +--
 .../camp/brooklyn/AbstractYamlTest.java         |  26 +++-
 .../brooklyn/camp/brooklyn/CatalogYamlTest.java |   8 --
 .../camp/brooklyn/ReferencedYamlTest.java       | 127 +++++++++++++++++++
 usage/camp/src/test/resources/yaml-ref-app.yaml |  21 +++
 .../src/test/resources/yaml-ref-catalog.yaml    |  21 +++
 .../src/test/resources/yaml-ref-entity.yaml     |  21 +++
 9 files changed, 291 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/201717a3/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java
index 9fcd5be..5a17cfe 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/BrooklynCampConstants.java
@@ -18,6 +18,10 @@
  */
 package io.brooklyn.camp.brooklyn;
 
+import java.util.Set;
+
+import com.google.common.collect.ImmutableSet;
+
 import io.brooklyn.camp.CampPlatform;
 import brooklyn.config.BrooklynServerConfig;
 import brooklyn.config.ConfigKey;
@@ -39,4 +43,5 @@ public class BrooklynCampConstants {
 
     public static final ConfigKey<CampPlatform> CAMP_PLATFORM = BrooklynServerConfig.CAMP_PLATFORM;
 
+    public static final Set<String> YAML_URL_PROTOCOL_WHITELIST = ImmutableSet.of("classpath", "http");
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/201717a3/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
index d57a99b..d7eaeb3 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
@@ -19,15 +19,16 @@
 package io.brooklyn.camp.brooklyn.spi.creation;
 
 import io.brooklyn.camp.CampPlatform;
-import io.brooklyn.camp.spi.AbstractResource;
+import io.brooklyn.camp.brooklyn.BrooklynCampConstants;
 import io.brooklyn.camp.spi.Assembly;
 import io.brooklyn.camp.spi.AssemblyTemplate;
 import io.brooklyn.camp.spi.AssemblyTemplate.Builder;
 import io.brooklyn.camp.spi.PlatformComponentTemplate;
 import io.brooklyn.camp.spi.collection.ResolvableLink;
 import io.brooklyn.camp.spi.instantiate.AssemblyTemplateInstantiator;
-import io.brooklyn.camp.spi.pdp.AssemblyTemplateConstructor;
 
+import java.io.IOException;
+import java.io.InputStreamReader;
 import java.io.Reader;
 import java.io.StringReader;
 import java.util.List;
@@ -43,22 +44,24 @@ import brooklyn.camp.brooklyn.api.HasBrooklynManagementContext;
 import brooklyn.catalog.BrooklynCatalog;
 import brooklyn.catalog.CatalogItem;
 import brooklyn.catalog.internal.BasicBrooklynCatalog.BrooklynLoaderTracker;
+import brooklyn.config.BrooklynServerConfig;
 import brooklyn.entity.Application;
 import brooklyn.entity.Entity;
 import brooklyn.entity.basic.BasicApplicationImpl;
 import brooklyn.entity.basic.Entities;
 import brooklyn.entity.basic.EntityLocal;
-import brooklyn.entity.basic.StartableApplication;
 import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.entity.trait.Startable;
 import brooklyn.management.ManagementContext;
 import brooklyn.management.Task;
 import brooklyn.management.classloading.BrooklynClassLoadingContext;
 import brooklyn.management.classloading.JavaBrooklynClassLoadingContext;
+import brooklyn.util.ResourceUtils;
 import brooklyn.util.collections.MutableList;
 import brooklyn.util.collections.MutableMap;
 import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.flags.TypeCoercions;
+import brooklyn.util.net.Urls;
 
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
@@ -211,16 +214,26 @@ public class BrooklynAssemblyTemplateInstantiator implements AssemblyTemplateSpe
                          
             if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+brooklynType+"; item="+item+"; loader="+loader+"; template="+template+"; encounteredCatalogTypes="+encounteredCatalogTypes);
 
-            EntitySpec<?> spec;
-            if (item == null || item.getJavaType() != null || entityResolver.isJavaTypePrefix()) {
-                spec = entityResolver.resolveSpec();
-            } else if (recursiveButTryJava) {
-                if (entityResolver.tryLoadEntityClass().isAbsent()) {
-                    throw new IllegalStateException("Recursive reference to " + brooklynType + " (and cannot be resolved as a Java type)");
+            EntitySpec<?> spec = null;
+            if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(Urls.getProtocol(brooklynType))) {
+                spec = tryResolveYamlURLReferenceSpec(brooklynType, loader, encounteredCatalogTypes);
+                if (spec != null) {
+                    entityResolver.populateSpec(spec);
+                }
+            }
+            
+            if (spec == null) {
+                if (item == null || item.getJavaType() != null || entityResolver.isJavaTypePrefix()) {
+                    spec = entityResolver.resolveSpec();
+                } else if (recursiveButTryJava) {
+                    if (entityResolver.tryLoadEntityClass().isAbsent()) {
+                        throw new IllegalStateException("Recursive reference to " + brooklynType + " (and cannot be resolved as a Java type)");
+                    }
+                    spec = entityResolver.resolveSpec();
+                } else {
+                    spec = resolveCatalogYamlReferenceSpec(mgmt, item, encounteredCatalogTypes);
+                    entityResolver.populateSpec(spec);
                 }
-                spec = entityResolver.resolveSpec();
-            } else {
-                spec = resolveCatalogYamlReferenceSpec(platform, mgmt, item, encounteredCatalogTypes);
             }
 
             BrooklynClassLoadingContext newLoader = entityResolver.loader;
@@ -231,16 +244,47 @@ public class BrooklynAssemblyTemplateInstantiator implements AssemblyTemplateSpe
         return result;
     }
 
-    private EntitySpec<?> resolveCatalogYamlReferenceSpec(CampPlatform platform,
+    private EntitySpec<?> tryResolveYamlURLReferenceSpec(
+            String brooklynType, BrooklynClassLoadingContext itemLoader, 
+            Set<String> encounteredCatalogTypes) {
+        ManagementContext mgmt = itemLoader.getManagementContext();
+        Reader yaml;
+        try {
+            ResourceUtils ru = ResourceUtils.create(this);
+            yaml = new InputStreamReader(ru.getResourceFromUrl(brooklynType), "UTF-8");
+        } catch (Exception e) {
+            log.warn("AssemblyTemplate type " + brooklynType + " which looks like a URL can't be fetched.", e);
+            return null;
+        }
+        try {
+            return resolveYamlSpec(mgmt, encounteredCatalogTypes, yaml, itemLoader);
+        } finally {
+            try {
+                yaml.close();
+            } catch (IOException e) {
+                throw Exceptions.propagate(e);
+            }
+        }
+    }
+
+    private EntitySpec<?> resolveCatalogYamlReferenceSpec(
             ManagementContext mgmt,
             CatalogItem<Entity, EntitySpec<?>> item,
             Set<String> encounteredCatalogTypes) {
         
         String yaml = item.getPlanYaml();
         Reader input = new StringReader(yaml);
+        BrooklynClassLoadingContext itemLoader = item.newClassLoadingContext(mgmt);
+        
+        return resolveYamlSpec(mgmt, encounteredCatalogTypes, input, itemLoader);
+    }
+
+    private EntitySpec<?> resolveYamlSpec(ManagementContext mgmt,
+            Set<String> encounteredCatalogTypes, Reader input,
+            BrooklynClassLoadingContext itemLoader) {
+        CampPlatform platform = BrooklynServerConfig.getCampPlatform(mgmt).get();
         
         AssemblyTemplate at;
-        BrooklynClassLoadingContext itemLoader = item.newClassLoadingContext(mgmt);
         BrooklynLoaderTracker.setLoader(itemLoader);
         try {
             at = platform.pdp().registerDeploymentPlan(input);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/201717a3/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityMatcher.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityMatcher.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityMatcher.java
index 218b6ea..28a3b2e 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityMatcher.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityMatcher.java
@@ -18,7 +18,7 @@
  */
 package io.brooklyn.camp.brooklyn.spi.creation;
 
-import io.brooklyn.camp.brooklyn.BrooklynCampPlatform;
+import io.brooklyn.camp.brooklyn.BrooklynCampConstants;
 import io.brooklyn.camp.spi.PlatformComponentTemplate;
 import io.brooklyn.camp.spi.PlatformComponentTemplate.Builder;
 import io.brooklyn.camp.spi.pdp.AssemblyTemplateConstructor;
@@ -41,6 +41,7 @@ import brooklyn.util.config.ConfigBag;
 import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.flags.FlagUtils;
 import brooklyn.util.flags.FlagUtils.FlagConfigKeyAndValueRecord;
+import brooklyn.util.net.Urls;
 import brooklyn.util.text.Strings;
 
 import com.google.common.collect.Lists;
@@ -66,18 +67,22 @@ public class BrooklynEntityMatcher implements PdpMatcher {
      * or null if not supported */
     protected String lookupType(Object deploymentPlanItem) {
         if (deploymentPlanItem instanceof Service) {
-            String name = ((Service)deploymentPlanItem).getName();
+            Service service = (Service)deploymentPlanItem;
+            
+            String name = service.getName();
             if (mgmt.getCatalog().getCatalogItem(name) != null) {
                 return name;
             }
-        }
-        if (deploymentPlanItem instanceof Service) {
-            String serviceType = ((Service)deploymentPlanItem).getServiceType();
+
+            String serviceType = service.getServiceType();
             BrooklynClassLoadingContext loader = BasicBrooklynCatalog.BrooklynLoaderTracker.getLoader();
             if (loader == null) loader = JavaBrooklynClassLoadingContext.newDefault(mgmt);
-            if (!BrooklynComponentTemplateResolver.Factory.supportsType(loader, serviceType))
-                return null;
-            return serviceType;
+            if (BrooklynComponentTemplateResolver.Factory.supportsType(loader, serviceType))
+                return serviceType;
+
+            if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(Urls.getProtocol(serviceType))) {
+                return serviceType;
+            }
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/201717a3/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/AbstractYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/AbstractYamlTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/AbstractYamlTest.java
index f27e0ca..13f5f14 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/AbstractYamlTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/AbstractYamlTest.java
@@ -25,11 +25,14 @@ import java.io.Reader;
 import java.io.StringReader;
 import java.util.Set;
 
+import org.codehaus.groovy.util.StringUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 
+import com.google.common.base.Joiner;
+
 import brooklyn.entity.Entity;
 import brooklyn.entity.basic.BrooklynTaskTags;
 import brooklyn.entity.basic.Entities;
@@ -92,6 +95,10 @@ public abstract class AbstractYamlTest {
         return new StringReader(builder.toString());
     }
     
+    protected Entity createAndStartApplication(String... multiLineYaml) throws Exception {
+        return createAndStartApplication(join(multiLineYaml));
+    }
+    
     protected Entity createAndStartApplication(String input) throws Exception {
         return createAndStartApplication(new StringReader(input));
     }
@@ -121,7 +128,24 @@ public abstract class AbstractYamlTest {
         return app;
     }
 
+    protected void addCatalogItem(String... catalogYaml) {
+        addCatalogItem(join(catalogYaml));
+    }
+
+    protected void addCatalogItem(String catalogYaml) {
+        mgmt().getCatalog().addItem(catalogYaml);
+    }
+
+    protected void deleteCatalogEntity(String catalogItem) {
+        mgmt().getCatalog().deleteCatalogItem(catalogItem);
+    }
+    
     protected Logger getLogger() {
         return LOG;
     }
-}
\ No newline at end of file
+
+    private String join(String[] catalogYaml) {
+        return Joiner.on("\n").join(catalogYaml);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/201717a3/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
index 48de5ed..6eb8b1e 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
@@ -145,12 +145,4 @@ public class CatalogYamlTest extends AbstractYamlTest {
         addCatalogItem(catalogYaml);
     }
 
-    private void addCatalogItem(String catalogYaml) {
-        mgmt().getCatalog().addItem(catalogYaml);
-    }
-
-    private void deleteCatalogEntity(String catalogItem) {
-        mgmt().getCatalog().deleteCatalogItem(catalogItem);
-    }
-    
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/201717a3/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java
new file mode 100644
index 0000000..d70497d
--- /dev/null
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java
@@ -0,0 +1,127 @@
+/*
+ * 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;
+
+import java.util.Collection;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.Entity;
+import brooklyn.entity.basic.BasicApplication;
+import brooklyn.entity.basic.BasicEntity;
+import brooklyn.test.entity.TestEntity;
+
+import com.google.common.collect.Iterables;
+
+public class ReferencedYamlTest extends AbstractYamlTest {
+    
+    @Test
+    public void testReferenceEntityYamlAsPlatformComponent() throws Exception {
+        String entityName = "Reference child name";
+        Entity app = createAndStartApplication(
+            "services:",
+            "- name: " + entityName,
+            "  type: classpath://yaml-ref-entity.yaml");
+        
+        checkChildEntitySpec(app, entityName);
+    }
+
+    @Test
+    public void testReferenceAppYamlAsPlatformComponent() throws Exception {
+        Entity app = createAndStartApplication(
+            "services:",
+            "- name: Reference child name",
+            "  type: classpath://yaml-ref-app.yaml");
+        
+        Assert.assertEquals(app.getChildren().size(), 0);
+        Assert.assertEquals(app.getDisplayName(), "Reference child name");
+
+        //child is a proxy so equality test won't do
+        Assert.assertEquals(app.getEntityType().getName(), BasicApplication.class.getName());
+    }
+
+    //the test fails, since the current code doesn't allow for nested yaml references
+    @Test(enabled = false)
+    public void testReferenceYamlAsChild() throws Exception {
+        String entityName = "Reference child name";
+        Entity createAndStartApplication = createAndStartApplication(
+            "services:",
+            "- type: brooklyn.entity.basic.BasicEntity",
+            "  brooklyn.children:",
+            "  - name: " + entityName,
+            "    type: classpath://yaml-ref-entity.yaml");
+        
+        checkGrandchildEntitySpec(createAndStartApplication, entityName);
+    }
+
+    @Test
+    public void testCatalogReferencingYamlUrl() throws Exception {
+        addCatalogItem(
+            "brooklyn.catalog:",
+            "  id: yaml.reference",
+            "services:",
+            "- type: classpath://yaml-ref-entity.yaml");
+        
+        String entityName = "YAML -> catalog item -> yaml url";
+        Entity app = createAndStartApplication(
+            "services:",
+            "- name: " + entityName,
+            "  type: yaml.reference");
+        
+        checkChildEntitySpec(app, entityName);
+    }
+
+    @Test
+    public void testYamlUrlReferencingCatalog() throws Exception {
+        addCatalogItem(
+            "brooklyn.catalog:",
+            "  id: yaml.basic",
+            "services:",
+            "- type: brooklyn.entity.basic.BasicEntity");
+        
+        String entityName = "YAML -> yaml url -> catalog item";
+        Entity app = createAndStartApplication(
+            "services:",
+            "- name: " + entityName,
+            "  type: classpath://yaml-ref-catalog.yaml");
+        
+        checkChildEntitySpec(app, entityName);
+    }
+
+    private void checkChildEntitySpec(Entity app, String entityName) {
+        Collection<Entity> children = app.getChildren();
+        Assert.assertEquals(children.size(), 1);
+        Entity child = Iterables.getOnlyElement(children);
+        Assert.assertEquals(child.getDisplayName(), entityName);
+        Assert.assertEquals(child.getEntityType().getName(), BasicEntity.class.getName());
+    }
+
+    private void checkGrandchildEntitySpec(Entity createAndStartApplication, String entityName) {
+        Collection<Entity> children = createAndStartApplication.getChildren();
+        Assert.assertEquals(children.size(), 1);
+        Entity child = Iterables.getOnlyElement(children);
+        Collection<Entity> grandChildren = child.getChildren();
+        Assert.assertEquals(grandChildren.size(), 1);
+        Entity grandChild = Iterables.getOnlyElement(grandChildren);
+        Assert.assertEquals(grandChild.getDisplayName(), entityName);
+        Assert.assertEquals(grandChild.getEntityType().getName(), BasicEntity.class.getName());
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/201717a3/usage/camp/src/test/resources/yaml-ref-app.yaml
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/resources/yaml-ref-app.yaml b/usage/camp/src/test/resources/yaml-ref-app.yaml
new file mode 100644
index 0000000..a26a4ab
--- /dev/null
+++ b/usage/camp/src/test/resources/yaml-ref-app.yaml
@@ -0,0 +1,21 @@
+# 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.
+#
+name: Basic app
+services:
+- name: service
+  type: brooklyn.entity.basic.BasicApplication
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/201717a3/usage/camp/src/test/resources/yaml-ref-catalog.yaml
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/resources/yaml-ref-catalog.yaml b/usage/camp/src/test/resources/yaml-ref-catalog.yaml
new file mode 100644
index 0000000..220deb9
--- /dev/null
+++ b/usage/camp/src/test/resources/yaml-ref-catalog.yaml
@@ -0,0 +1,21 @@
+# 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.
+#
+name: Basic app
+services:
+- name: service
+  type: yaml.basic
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/201717a3/usage/camp/src/test/resources/yaml-ref-entity.yaml
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/resources/yaml-ref-entity.yaml b/usage/camp/src/test/resources/yaml-ref-entity.yaml
new file mode 100644
index 0000000..8d27427
--- /dev/null
+++ b/usage/camp/src/test/resources/yaml-ref-entity.yaml
@@ -0,0 +1,21 @@
+# 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.
+#
+name: Basic entity
+services:
+- name: service
+  type: brooklyn.entity.basic.BasicEntity
\ No newline at end of file


[07/10] git commit: Add tests

Posted by al...@apache.org.
Add tests

  * Catalog item does not leak bundles to child catalog items
  * Catalog item DOES leak bundles to URL referenced YAMLs


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

Branch: refs/heads/master
Commit: f1425269dab14b386da5870ab010572a66b12d38
Parents: 2250609
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Jul 16 13:55:04 2014 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Thu Jul 17 18:54:29 2014 +0300

----------------------------------------------------------------------
 .../brooklyn/camp/brooklyn/CatalogYamlTest.java | 39 +++++++++++++++++++-
 .../camp/brooklyn/ReferencedYamlTest.java       | 29 +++++++++++++++
 .../yaml-ref-bundle-without-libraries.yaml      | 19 ++++++++++
 3 files changed, 86 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1425269/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
index 592160c..78f7c0d 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
@@ -51,7 +51,7 @@ public class CatalogYamlTest extends AbstractYamlTest {
         String registeredTypeName = "my.catalog.app.id.launch";
         registerAndLaunchAndAssertSimpleEntity(registeredTypeName, SIMPLE_ENTITY_TYPE);
     }
-    
+
     @Test
     public void testLaunchApplicationWithCatalogReferencingOtherCatalog() throws Exception {
         String referencedRegisteredTypeName = "my.catalog.app.id.referenced";
@@ -140,6 +140,43 @@ public class CatalogYamlTest extends AbstractYamlTest {
         }
     }
 
+    /**
+     * Tests that a catalog item referenced by another
+     * catalog item won't have access to the parent's bundles.
+     */
+    @Test
+    public void testParentCatalogDoesNotLeakBundlesToChildCatalogItems() throws Exception {
+        String childCatalogId = "my.catalog.app.id.no_bundles";
+        String parentCatalogId = "my.catalog.app.id.parent";
+        addCatalogItem(
+                "brooklyn.catalog:",
+                "  id: " + childCatalogId,
+                "",
+                "services:",
+                "- type: " + SIMPLE_ENTITY_TYPE);
+        
+        addCatalogItem(
+                "brooklyn.catalog:",
+                "  id: " + parentCatalogId,
+                "  libraries:",
+                "  - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+                "",
+                "services:",
+                "- type: " + childCatalogId);
+        
+        try {
+            createAndStartApplication(
+                    "services:",
+                    "- type: " + parentCatalogId);
+        } catch (UnsupportedOperationException e) {
+            assertTrue(e.getMessage().endsWith("cannot be matched"));
+            assertTrue(e.getMessage().contains(SIMPLE_ENTITY_TYPE));
+        }
+
+        deleteCatalogEntity(parentCatalogId);
+        deleteCatalogEntity(childCatalogId);
+    }
+
     private void registerAndLaunchAndAssertSimpleEntity(String registeredTypeName, String serviceType) throws Exception {
         addCatalogOSGiEntity(registeredTypeName, serviceType);
         try {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1425269/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java
index b2ad68b..05bb8c0 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java
@@ -26,6 +26,7 @@ import org.testng.annotations.Test;
 import brooklyn.entity.Entity;
 import brooklyn.entity.basic.BasicApplication;
 import brooklyn.entity.basic.BasicEntity;
+import brooklyn.management.osgi.OsgiStandaloneTest;
 
 import com.google.common.collect.Iterables;
 
@@ -123,6 +124,34 @@ public class ReferencedYamlTest extends AbstractYamlTest {
         checkChildEntitySpec(app, entityName);
     }
 
+    /**
+     * Tests that a YAML referenced by URL from a catalog item
+     * will have access to the catalog item's bundles.
+     */
+    @Test
+    public void testCatalogLeaksBundlesToReferencedYaml() throws Exception {
+        String parentCatalogId = "my.catalog.app.id.url.parent";
+        addCatalogItem(
+            "brooklyn.catalog:",
+            "  id: " + parentCatalogId,
+            "  libraries:",
+            "  - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+            "",
+            "services:",
+            "- type: classpath://yaml-ref-bundle-without-libraries.yaml");
+
+        Entity app = createAndStartApplication(
+            "services:",
+                "- type: " + parentCatalogId);
+        
+        Collection<Entity> children = app.getChildren();
+        Assert.assertEquals(children.size(), 1);
+        Entity child = Iterables.getOnlyElement(children);
+        Assert.assertEquals(child.getEntityType().getName(), "brooklyn.osgi.tests.SimpleEntity");
+
+        deleteCatalogEntity(parentCatalogId);
+    }
+
     private void checkChildEntitySpec(Entity app, String entityName) {
         Collection<Entity> children = app.getChildren();
         Assert.assertEquals(children.size(), 1);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f1425269/usage/camp/src/test/resources/yaml-ref-bundle-without-libraries.yaml
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/resources/yaml-ref-bundle-without-libraries.yaml b/usage/camp/src/test/resources/yaml-ref-bundle-without-libraries.yaml
new file mode 100644
index 0000000..f2ae9cb
--- /dev/null
+++ b/usage/camp/src/test/resources/yaml-ref-bundle-without-libraries.yaml
@@ -0,0 +1,19 @@
+# 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.
+#
+services:
+- type: brooklyn.osgi.tests.SimpleEntity


[06/10] git commit: Remove unnecessary name in YAML.

Posted by al...@apache.org.
Remove unnecessary name in YAML.


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

Branch: refs/heads/master
Commit: 22506097a692c5055d1043a6f9e38d57913a863d
Parents: 6bc8d49
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Jul 16 13:33:37 2014 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Wed Jul 16 15:13:43 2014 +0300

----------------------------------------------------------------------
 .../test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java   | 6 ------
 1 file changed, 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/22506097/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
index 7cc5235..592160c 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
@@ -180,9 +180,6 @@ public class CatalogYamlTest extends AbstractYamlTest {
     
     private void addCatalogOSGiEntity(String registeredTypeName, String serviceType) {
         addCatalogItem(
-            "name: "+registeredTypeName,
-            // FIXME name above should be unnecessary -- slight problem somewhere currently
-            // as testListApplicationYaml fails without the line above
             "brooklyn.catalog:",
             "  id: " + registeredTypeName,
             "  name: My Catalog App",
@@ -198,9 +195,6 @@ public class CatalogYamlTest extends AbstractYamlTest {
 
     private void addCatalogChildOSGiEntity(String registeredTypeName, String serviceType) {
         addCatalogItem(
-            "name: "+registeredTypeName,
-            // FIXME name above should be unnecessary -- slight problem somewhere currently
-            // as testListApplicationYaml fails without the line above
             "brooklyn.catalog:",
             "  id: " + registeredTypeName,
             "  name: My Catalog App",


[10/10] git commit: This closes #71

Posted by al...@apache.org.
This closes #71


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

Branch: refs/heads/master
Commit: bf71719c80edc5411f5383bb058314e6fe6989cb
Parents: 4b7e335 977a6be
Author: Aled Sage <al...@gmail.com>
Authored: Fri Jul 18 11:00:18 2014 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Jul 18 11:00:18 2014 +0100

----------------------------------------------------------------------
 .../camp/brooklyn/BrooklynCampConstants.java    |   5 +
 .../BrooklynAssemblyTemplateInstantiator.java   | 154 ++++++++--------
 .../BrooklynComponentTemplateResolver.java      |  25 ++-
 .../spi/creation/BrooklynEntityMatcher.java     |  28 ++-
 .../creation/ChefComponentTemplateResolver.java |   2 +-
 .../camp/brooklyn/AbstractYamlTest.java         |  26 ++-
 .../brooklyn/camp/brooklyn/CatalogYamlTest.java | 142 ++++++++++++---
 .../camp/brooklyn/ReferencedYamlTest.java       | 174 +++++++++++++++++++
 usage/camp/src/test/resources/yaml-ref-app.yaml |  21 +++
 .../yaml-ref-bundle-without-libraries.yaml      |  19 ++
 .../src/test/resources/yaml-ref-catalog.yaml    |  21 +++
 .../src/test/resources/yaml-ref-entity.yaml     |  21 +++
 12 files changed, 526 insertions(+), 112 deletions(-)
----------------------------------------------------------------------



[08/10] git commit: Log a warning

Posted by al...@apache.org.
Log a warning

in case the protocol of a url referenced YAML is not white listed


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

Branch: refs/heads/master
Commit: 977a6be7bb54abd305871bf93841417198d4ebc0
Parents: f142526
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Thu Jul 17 19:13:51 2014 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Thu Jul 17 19:14:25 2014 +0300

----------------------------------------------------------------------
 .../BrooklynAssemblyTemplateInstantiator.java        | 15 +++++++++++----
 .../brooklyn/spi/creation/BrooklynEntityMatcher.java | 11 +++++++++--
 2 files changed, 20 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/977a6be7/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
index a5a67ea..2457812 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
@@ -225,10 +225,17 @@ public class BrooklynAssemblyTemplateInstantiator implements AssemblyTemplateSpe
         if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+brooklynType+"; item="+item+"; loader="+entityResolver.loader+"; encounteredCatalogTypes="+encounteredCatalogTypes);
 
         EntitySpec<?> spec = null;
-        if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(Urls.getProtocol(brooklynType))) {
-            spec = tryResolveYamlURLReferenceSpec(brooklynType, entityResolver.loader, encounteredCatalogTypes);
-            if (spec != null) {
-                entityResolver.populateSpec(spec);
+        String protocol = Urls.getProtocol(brooklynType);
+        if (protocol != null) {
+            if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(protocol)) {
+                spec = tryResolveYamlURLReferenceSpec(brooklynType, entityResolver.loader, encounteredCatalogTypes);
+                if (spec != null) {
+                    entityResolver.populateSpec(spec);
+                }
+            } else {
+                log.warn("The reference " + brooklynType + " looks like an URL but the protocol " + 
+                        protocol + " isn't white listed (" + BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST + "). " +
+                        "Will try to load it as catalog item or java type.");
             }
         }
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/977a6be7/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityMatcher.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityMatcher.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityMatcher.java
index 28a3b2e..bd54f3e 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityMatcher.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynEntityMatcher.java
@@ -80,8 +80,15 @@ public class BrooklynEntityMatcher implements PdpMatcher {
             if (BrooklynComponentTemplateResolver.Factory.supportsType(loader, serviceType))
                 return serviceType;
 
-            if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(Urls.getProtocol(serviceType))) {
-                return serviceType;
+            String protocol = Urls.getProtocol(serviceType);
+            if (protocol != null) {
+                if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(protocol)) {
+                    return serviceType;
+                } else {
+                    log.warn("The reference '" + serviceType + "' looks like an URL but the protocol '" + 
+                            protocol + "' isn't white listed " + BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST + ". " +
+                            "Not recognized as catalog item or java item as well!");
+                }
             }
         }
         return null;


[05/10] git commit: Resolve catalog items and yaml URLs from child entities as well.

Posted by al...@apache.org.
Resolve catalog items and yaml URLs from child entities as well.


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

Branch: refs/heads/master
Commit: 6bc8d49f954e4bdbf186fa9581a57766465f1f98
Parents: 201717a
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Jul 16 13:20:01 2014 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Wed Jul 16 15:13:37 2014 +0300

----------------------------------------------------------------------
 .../BrooklynAssemblyTemplateInstantiator.java   |  78 +++++++-------
 .../BrooklynComponentTemplateResolver.java      |   2 +-
 .../brooklyn/camp/brooklyn/CatalogYamlTest.java | 105 ++++++++++++++++---
 .../camp/brooklyn/ReferencedYamlTest.java       |  24 ++++-
 4 files changed, 150 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6bc8d49f/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
index d7eaeb3..a5a67ea 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
@@ -204,44 +204,51 @@ public class BrooklynAssemblyTemplateInstantiator implements AssemblyTemplateSpe
         for (ResolvableLink<PlatformComponentTemplate> ctl: template.getPlatformComponentTemplates().links()) {
             PlatformComponentTemplate appChildComponentTemplate = ctl.resolve();
             BrooklynComponentTemplateResolver entityResolver = BrooklynComponentTemplateResolver.Factory.newInstance(loader, appChildComponentTemplate);
-            ManagementContext mgmt = loader.getManagementContext();
+            EntitySpec<?> spec = resolveSpec(entityResolver, encounteredCatalogTypes);
+            
+            result.add(spec);
+        }
+        return result;
+    }
 
-            String brooklynType = entityResolver.getBrooklynType();
-            CatalogItem<Entity, EntitySpec<?>> item = entityResolver.getCatalogItem();
+    private EntitySpec<?> resolveSpec(
+            BrooklynComponentTemplateResolver entityResolver, 
+            Set<String> encounteredCatalogTypes) {
+        ManagementContext mgmt = entityResolver.loader.getManagementContext();
 
-            boolean firstOccurrence = encounteredCatalogTypes.add(brooklynType);
-            boolean recursiveButTryJava = !firstOccurrence;
-                         
-            if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+brooklynType+"; item="+item+"; loader="+loader+"; template="+template+"; encounteredCatalogTypes="+encounteredCatalogTypes);
+        String brooklynType = entityResolver.getBrooklynType();
+        CatalogItem<Entity, EntitySpec<?>> item = entityResolver.getCatalogItem();
 
-            EntitySpec<?> spec = null;
-            if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(Urls.getProtocol(brooklynType))) {
-                spec = tryResolveYamlURLReferenceSpec(brooklynType, loader, encounteredCatalogTypes);
-                if (spec != null) {
-                    entityResolver.populateSpec(spec);
-                }
+        boolean firstOccurrence = encounteredCatalogTypes.add(brooklynType);
+        boolean recursiveButTryJava = !firstOccurrence;
+        
+        if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+brooklynType+"; item="+item+"; loader="+entityResolver.loader+"; encounteredCatalogTypes="+encounteredCatalogTypes);
+
+        EntitySpec<?> spec = null;
+        if (BrooklynCampConstants.YAML_URL_PROTOCOL_WHITELIST.contains(Urls.getProtocol(brooklynType))) {
+            spec = tryResolveYamlURLReferenceSpec(brooklynType, entityResolver.loader, encounteredCatalogTypes);
+            if (spec != null) {
+                entityResolver.populateSpec(spec);
             }
-            
-            if (spec == null) {
-                if (item == null || item.getJavaType() != null || entityResolver.isJavaTypePrefix()) {
-                    spec = entityResolver.resolveSpec();
-                } else if (recursiveButTryJava) {
-                    if (entityResolver.tryLoadEntityClass().isAbsent()) {
-                        throw new IllegalStateException("Recursive reference to " + brooklynType + " (and cannot be resolved as a Java type)");
-                    }
-                    spec = entityResolver.resolveSpec();
-                } else {
-                    spec = resolveCatalogYamlReferenceSpec(mgmt, item, encounteredCatalogTypes);
-                    entityResolver.populateSpec(spec);
+        }
+        
+        if (spec == null) {
+            if (item == null || item.getJavaType() != null || entityResolver.isJavaTypePrefix()) {
+                spec = entityResolver.resolveSpec();
+            } else if (recursiveButTryJava) {
+                if (entityResolver.tryLoadEntityClass().isAbsent()) {
+                    throw new IllegalStateException("Recursive reference to " + brooklynType + " (and cannot be resolved as a Java type)");
                 }
+                spec = entityResolver.resolveSpec();
+            } else {
+                spec = resolveCatalogYamlReferenceSpec(mgmt, item, encounteredCatalogTypes);
+                entityResolver.populateSpec(spec);
             }
-
-            BrooklynClassLoadingContext newLoader = entityResolver.loader;
-            buildChildrenEntitySpecs(newLoader, spec, entityResolver.getChildren(appChildComponentTemplate.getCustomAttributes()));
-            
-            result.add(spec);
         }
-        return result;
+
+        BrooklynClassLoadingContext newLoader = entityResolver.loader;
+        buildChildrenEntitySpecs(newLoader, spec, entityResolver.getChildren(entityResolver.attrs.getAllConfig()), encounteredCatalogTypes);
+        return spec;
     }
 
     private EntitySpec<?> tryResolveYamlURLReferenceSpec(
@@ -310,17 +317,12 @@ public class BrooklynAssemblyTemplateInstantiator implements AssemblyTemplateSpe
         }
     }
 
-    protected void buildChildrenEntitySpecs(BrooklynClassLoadingContext loader, EntitySpec<?> parent, List<Map<String, Object>> childConfig) {
+    protected void buildChildrenEntitySpecs(BrooklynClassLoadingContext loader, EntitySpec<?> parent, List<Map<String, Object>> childConfig, Set<String> encounteredCatalogTypes) {
         if (childConfig != null) {
             for (Map<String, Object> childAttrs : childConfig) {
                 BrooklynComponentTemplateResolver entityResolver = BrooklynComponentTemplateResolver.Factory.newInstance(loader, childAttrs);
-                EntitySpec<? extends Entity> spec = entityResolver.resolveSpec();
+                EntitySpec<? extends Entity> spec = resolveSpec(entityResolver, encounteredCatalogTypes);
                 parent.child(spec);
-
-                // get the new loader in case the OSGi bundles from parent were added;
-                // not so important now but if we start working with versions this may be important
-                BrooklynClassLoadingContext newLoader = entityResolver.loader;
-                buildChildrenEntitySpecs(newLoader, spec, entityResolver.getChildren(childAttrs));
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6bc8d49f/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 9d3f43c..155342a 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
@@ -395,7 +395,7 @@ public class BrooklynComponentTemplateResolver {
     }
 
     @SuppressWarnings("unchecked")
-    public List<Map<String, Object>> getChildren(Map<String, Object> attrs) {
+    protected List<Map<String, Object>> getChildren(Map<String, Object> attrs) {
         if (attrs==null) return null;
         return (List<Map<String, Object>>) attrs.get("brooklyn.children");
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6bc8d49f/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
index 6eb8b1e..7cc5235 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/CatalogYamlTest.java
@@ -22,10 +22,13 @@ import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
+import java.util.Collection;
+
 import org.testng.annotations.Test;
 
 import brooklyn.catalog.CatalogItem;
 import brooklyn.entity.Entity;
+import brooklyn.entity.basic.BasicEntity;
 import brooklyn.management.osgi.OsgiStandaloneTest;
 
 import com.google.common.collect.Iterables;
@@ -41,7 +44,6 @@ public class CatalogYamlTest extends AbstractYamlTest {
         
         CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem(registeredTypeName);
         assertEquals(item.getRegisteredTypeName(), registeredTypeName);
-        
     }
 
     @Test
@@ -49,7 +51,7 @@ public class CatalogYamlTest extends AbstractYamlTest {
         String registeredTypeName = "my.catalog.app.id.launch";
         registerAndLaunchAndAssertSimpleEntity(registeredTypeName, SIMPLE_ENTITY_TYPE);
     }
-
+    
     @Test
     public void testLaunchApplicationWithCatalogReferencingOtherCatalog() throws Exception {
         String referencedRegisteredTypeName = "my.catalog.app.id.referenced";
@@ -68,6 +70,35 @@ public class CatalogYamlTest extends AbstractYamlTest {
     }
 
     @Test
+    public void testLaunchApplicationChildWithCatalogReferencingOtherCatalog() throws Exception {
+        String referencedRegisteredTypeName = "my.catalog.app.id.child.referenced";
+        String referrerRegisteredTypeName = "my.catalog.app.id.child.referring";
+        addCatalogOSGiEntity(referencedRegisteredTypeName, SIMPLE_ENTITY_TYPE);
+        addCatalogChildOSGiEntity(referrerRegisteredTypeName, referencedRegisteredTypeName);
+
+        Entity app = createAndStartApplication(
+            "name: simple-app-yaml",
+            "location: localhost",
+            "services:",
+            "- serviceType: "+BasicEntity.class.getName(),
+            "  brooklyn.children:",
+            "  - type: " + referrerRegisteredTypeName);
+        
+        Collection<Entity> children = app.getChildren();
+        assertEquals(children.size(), 1);
+        Entity child = Iterables.getOnlyElement(children);
+        assertEquals(child.getEntityType().getName(), BasicEntity.class.getName());
+        Collection<Entity> grandChildren = child.getChildren();
+        assertEquals(grandChildren.size(), 1);
+        Entity grandChild = Iterables.getOnlyElement(grandChildren);
+        assertEquals(grandChild.getEntityType().getName(), BasicEntity.class.getName());
+        Collection<Entity> grandGrandChildren = grandChild.getChildren();
+        assertEquals(grandGrandChildren.size(), 1);
+        Entity grandGrandChild = Iterables.getOnlyElement(grandGrandChildren);
+        assertEquals(grandGrandChild.getEntityType().getName(), SIMPLE_ENTITY_TYPE);
+    }
+
+    @Test
     public void testLaunchApplicationWithTypeUsingJavaColonPrefix() throws Exception {
         String registeredTypeName = SIMPLE_ENTITY_TYPE;
         String serviceName = "java:"+SIMPLE_ENTITY_TYPE;
@@ -86,6 +117,28 @@ public class CatalogYamlTest extends AbstractYamlTest {
         String registeredTypeName = "self.referencing.type";
         registerAndLaunchFailsWithRecursionError(registeredTypeName, registeredTypeName);
     }
+    
+    @Test
+    public void testLaunchApplicationChildLoopCatalogIdFails() throws Exception {
+        String referrerRegisteredTypeName = "my.catalog.app.id.child.referring";
+        addCatalogChildOSGiEntity(referrerRegisteredTypeName, referrerRegisteredTypeName);
+
+        try {
+            createAndStartApplication(
+                "name: simple-app-yaml",
+                "location: localhost",
+                "services:",
+                "- serviceType: "+BasicEntity.class.getName(),
+                "  brooklyn.children:",
+                "  - type: " + referrerRegisteredTypeName);
+            
+                fail("Expected to throw IllegalStateException");
+        } catch (IllegalStateException e) {
+            assertTrue(e.getMessage().contains("Recursive reference to "+referrerRegisteredTypeName));
+        } finally {
+            deleteCatalogEntity(referrerRegisteredTypeName);
+        }
+    }
 
     private void registerAndLaunchAndAssertSimpleEntity(String registeredTypeName, String serviceType) throws Exception {
         addCatalogOSGiEntity(registeredTypeName, serviceType);
@@ -126,23 +179,41 @@ public class CatalogYamlTest extends AbstractYamlTest {
     }
     
     private void addCatalogOSGiEntity(String registeredTypeName, String serviceType) {
-        String catalogYaml =
-            "name: "+registeredTypeName+"\n"+
+        addCatalogItem(
+            "name: "+registeredTypeName,
+            // FIXME name above should be unnecessary -- slight problem somewhere currently
+            // as testListApplicationYaml fails without the line above
+            "brooklyn.catalog:",
+            "  id: " + registeredTypeName,
+            "  name: My Catalog App",
+            "  description: My description",
+            "  icon_url: classpath://path/to/myicon.jpg",
+            "  version: 0.1.2",
+            "  libraries:",
+            "  - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+            "",
+            "services:",
+            "- type: " + serviceType);
+    }
+
+    private void addCatalogChildOSGiEntity(String registeredTypeName, String serviceType) {
+        addCatalogItem(
+            "name: "+registeredTypeName,
             // FIXME name above should be unnecessary -- slight problem somewhere currently
             // as testListApplicationYaml fails without the line above
-            "brooklyn.catalog:\n"+
-            "  id: " + registeredTypeName + "\n"+
-            "  name: My Catalog App\n"+
-            "  description: My description\n"+
-            "  icon_url: classpath://path/to/myicon.jpg\n"+
-            "  version: 0.1.2\n"+
-            "  libraries:\n"+
-            "  - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL + "\n"+
-            "\n"+
-            "services:\n"+
-            "- type: " + serviceType;
-
-        addCatalogItem(catalogYaml);
+            "brooklyn.catalog:",
+            "  id: " + registeredTypeName,
+            "  name: My Catalog App",
+            "  description: My description",
+            "  icon_url: classpath://path/to/myicon.jpg",
+            "  version: 0.1.2",
+            "  libraries:",
+            "  - url: " + OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_URL,
+            "",
+            "services:",
+            "- type: " + BasicEntity.class.getName(),
+            "  brooklyn.children:",
+            "  - type: " + serviceType);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6bc8d49f/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java
index d70497d..b2ad68b 100644
--- a/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java
+++ b/usage/camp/src/test/java/io/brooklyn/camp/brooklyn/ReferencedYamlTest.java
@@ -26,7 +26,6 @@ import org.testng.annotations.Test;
 import brooklyn.entity.Entity;
 import brooklyn.entity.basic.BasicApplication;
 import brooklyn.entity.basic.BasicEntity;
-import brooklyn.test.entity.TestEntity;
 
 import com.google.common.collect.Iterables;
 
@@ -44,6 +43,15 @@ public class ReferencedYamlTest extends AbstractYamlTest {
     }
 
     @Test
+    public void testAnonymousReferenceEntityYamlAsPlatformComponent() throws Exception {
+        Entity app = createAndStartApplication(
+            "services:",
+            "- type: classpath://yaml-ref-entity.yaml");
+        
+        checkChildEntitySpec(app, "service");
+    }
+
+    @Test
     public void testReferenceAppYamlAsPlatformComponent() throws Exception {
         Entity app = createAndStartApplication(
             "services:",
@@ -57,8 +65,7 @@ public class ReferencedYamlTest extends AbstractYamlTest {
         Assert.assertEquals(app.getEntityType().getName(), BasicApplication.class.getName());
     }
 
-    //the test fails, since the current code doesn't allow for nested yaml references
-    @Test(enabled = false)
+    @Test
     public void testReferenceYamlAsChild() throws Exception {
         String entityName = "Reference child name";
         Entity createAndStartApplication = createAndStartApplication(
@@ -72,6 +79,17 @@ public class ReferencedYamlTest extends AbstractYamlTest {
     }
 
     @Test
+    public void testAnonymousReferenceYamlAsChild() throws Exception {
+        Entity createAndStartApplication = createAndStartApplication(
+            "services:",
+            "- type: brooklyn.entity.basic.BasicEntity",
+            "  brooklyn.children:",
+            "  - type: classpath://yaml-ref-entity.yaml");
+        
+        checkGrandchildEntitySpec(createAndStartApplication, "service");
+    }
+
+    @Test
     public void testCatalogReferencingYamlUrl() throws Exception {
         addCatalogItem(
             "brooklyn.catalog:",


[04/10] git commit: Split spec creation in separate steps to allow re-use.

Posted by al...@apache.org.
Split spec creation in separate steps to allow re-use.


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

Branch: refs/heads/master
Commit: b982e6fea941b499b21736f12bddaa55437f3e38
Parents: 918a268
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Jul 16 11:22:16 2014 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Wed Jul 16 13:20:22 2014 +0300

----------------------------------------------------------------------
 .../creation/BrooklynComponentTemplateResolver.java  | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b982e6fe/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 7bd71f6..9d3f43c 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
@@ -218,11 +218,18 @@ public class BrooklynComponentTemplateResolver {
     }
 
     /** resolves the spec, updating the loader if a catalog item is loaded */
-    @SuppressWarnings("unchecked")
     public <T extends Entity> EntitySpec<T> resolveSpec() {
         if (alreadyBuilt.getAndSet(true))
             throw new IllegalStateException("Spec can only be used once: "+this);
+        
+        EntitySpec<T> spec = createSpec();
+        populateSpec(spec);
+        
+        return spec;
+    }
 
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    private <T extends Entity> EntitySpec<T> createSpec() {
         // ensure loader is updated
         getCatalogItem();
         
@@ -238,7 +245,11 @@ public class BrooklynComponentTemplateResolver {
             List<Class<?>> additionalInterfaceClazzes = Reflections.getAllInterfaces(type);
             spec = EntitySpec.create(interfaceclazz).impl(type).additionalInterfaces(additionalInterfaceClazzes);
         }
+        return spec;
+    }
 
+    //called from BrooklynAssemblyTemplateInstantiator as well
+    protected <T extends Entity> void populateSpec(EntitySpec<T> spec) {
         String name, templateId=null, planId=null;
         if (template.isPresent()) {
             name = template.get().getName();
@@ -262,8 +273,6 @@ public class BrooklynComponentTemplateResolver {
             spec.locations(childLocations);
         
         decorateSpec(spec);
-        
-        return spec;
     }
 
     protected <T extends Entity> void decorateSpec(EntitySpec<T> spec) {


[02/10] git commit: Rename getCatalogIdOrJavaType to getBrooklynType.

Posted by al...@apache.org.
Rename getCatalogIdOrJavaType to getBrooklynType.

The type now can be one of:
  * catalog id
  * java class name
  * URL to yaml file


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

Branch: refs/heads/master
Commit: 918a2687053de57560e2a68b858c8a9b117a6f5d
Parents: d5a249f
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Jul 16 11:13:57 2014 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Wed Jul 16 13:20:21 2014 +0300

----------------------------------------------------------------------
 .../spi/creation/BrooklynAssemblyTemplateInstantiator.java   | 8 ++++----
 .../spi/creation/BrooklynComponentTemplateResolver.java      | 8 ++++----
 .../brooklyn/spi/creation/ChefComponentTemplateResolver.java | 2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/918a2687/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
index 7a0ab81..d57a99b 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java
@@ -203,20 +203,20 @@ public class BrooklynAssemblyTemplateInstantiator implements AssemblyTemplateSpe
             BrooklynComponentTemplateResolver entityResolver = BrooklynComponentTemplateResolver.Factory.newInstance(loader, appChildComponentTemplate);
             ManagementContext mgmt = loader.getManagementContext();
 
-            String catalogIdOrJavaType = entityResolver.getCatalogIdOrJavaType();
+            String brooklynType = entityResolver.getBrooklynType();
             CatalogItem<Entity, EntitySpec<?>> item = entityResolver.getCatalogItem();
 
-            boolean firstOccurrence = encounteredCatalogTypes.add(catalogIdOrJavaType);
+            boolean firstOccurrence = encounteredCatalogTypes.add(brooklynType);
             boolean recursiveButTryJava = !firstOccurrence;
                          
-            if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+catalogIdOrJavaType+"; item="+item+"; loader="+loader+"; template="+template+"; encounteredCatalogTypes="+encounteredCatalogTypes);
+            if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+brooklynType+"; item="+item+"; loader="+loader+"; template="+template+"; encounteredCatalogTypes="+encounteredCatalogTypes);
 
             EntitySpec<?> spec;
             if (item == null || item.getJavaType() != null || entityResolver.isJavaTypePrefix()) {
                 spec = entityResolver.resolveSpec();
             } else if (recursiveButTryJava) {
                 if (entityResolver.tryLoadEntityClass().isAbsent()) {
-                    throw new IllegalStateException("Recursive reference to " + catalogIdOrJavaType + " (and cannot be resolved as a Java type)");
+                    throw new IllegalStateException("Recursive reference to " + brooklynType + " (and cannot be resolved as a Java type)");
                 }
                 spec = entityResolver.resolveSpec();
             } else {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/918a2687/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 2f000e8..7bd71f6 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
@@ -158,7 +158,7 @@ public class BrooklynComponentTemplateResolver {
         return type != null && (type.toLowerCase().startsWith("java:") || type.toLowerCase().startsWith("brooklyn:java:"));
     }
 
-    protected String getCatalogIdOrJavaType() {
+    protected String getBrooklynType() {
         String type = getDeclaredType();
         type = Strings.removeFromStart(type, "brooklyn:", "java:");
         if (type == null) return null;
@@ -179,7 +179,7 @@ public class BrooklynComponentTemplateResolver {
      */
     @Nullable
     public CatalogItem<Entity,EntitySpec<?>> getCatalogItem() {
-        String type = getCatalogIdOrJavaType();
+        String type = getBrooklynType();
         if (type != null) {
             return loader.getManagementContext().getCatalog().getCatalogItem(Entity.class, type);
         } else {
@@ -190,7 +190,7 @@ public class BrooklynComponentTemplateResolver {
     public boolean canResolve() {
         if (getCatalogItem()!=null) 
             return true;
-        if (loader.tryLoadClass(getCatalogIdOrJavaType(), Entity.class).isPresent())
+        if (loader.tryLoadClass(getBrooklynType(), Entity.class).isPresent())
             return true;
         return false;
     }
@@ -203,7 +203,7 @@ public class BrooklynComponentTemplateResolver {
     /** tries to load the Java entity class */
     public Maybe<Class<? extends Entity>> tryLoadEntityClass() {
         CatalogItem<Entity, EntitySpec<?>> item = getCatalogItem();
-        String typeName = getCatalogIdOrJavaType();
+        String typeName = getBrooklynType();
         
         if (item!=null) {
             // add additional bundles

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/918a2687/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/ChefComponentTemplateResolver.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/ChefComponentTemplateResolver.java b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/ChefComponentTemplateResolver.java
index adb3537..83bb7cb 100644
--- a/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/ChefComponentTemplateResolver.java
+++ b/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/ChefComponentTemplateResolver.java
@@ -35,7 +35,7 @@ public class ChefComponentTemplateResolver extends BrooklynComponentTemplateReso
     }
 
     @Override
-    protected String getCatalogIdOrJavaType() {
+    protected String getBrooklynType() {
         return ChefEntity.class.getName();
     }
 


[09/10] git commit: fix intermittent issue with apache rat

Posted by al...@apache.org.
fix intermittent issue with apache rat

those files are not always considered binary, but they are not directly used by code


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

Branch: refs/heads/master
Commit: 4b7e3359333d718645d2ebe70a1ca2740cd09eb0
Parents: c3f0455
Author: Andrea Turli <an...@gmail.com>
Authored: Wed Jul 16 17:08:38 2014 +0200
Committer: Aled Sage <al...@gmail.com>
Committed: Fri Jul 18 10:22:53 2014 +0100

----------------------------------------------------------------------
 usage/launcher/src/test/resources/client_cert | Bin 595 -> 0 bytes
 usage/launcher/src/test/resources/server_cert | Bin 595 -> 0 bytes
 2 files changed, 0 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4b7e3359/usage/launcher/src/test/resources/client_cert
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/client_cert b/usage/launcher/src/test/resources/client_cert
deleted file mode 100644
index aea2a07..0000000
Binary files a/usage/launcher/src/test/resources/client_cert and /dev/null differ

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/4b7e3359/usage/launcher/src/test/resources/server_cert
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/server_cert b/usage/launcher/src/test/resources/server_cert
deleted file mode 100644
index d8a172b..0000000
Binary files a/usage/launcher/src/test/resources/server_cert and /dev/null differ