brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [49/50] git commit: Support catalog type + java type name matching
Date Wed, 09 Jul 2014 21:47:02 GMT
Support catalog type + java type name matching


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

Branch: refs/heads/master
Commit: 6d0148606991f303f6a1bc37b45ade109c301a22
Parents: 69f5e8d
Author: Aled Sage <aled.sage@gmail.com>
Authored: Wed Jul 9 22:04:34 2014 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Wed Jul 9 22:34:48 2014 +0100

----------------------------------------------------------------------
 .../BrooklynAssemblyTemplateInstantiator.java      | 17 ++++++++++-------
 .../rest/resources/CatalogBundleResourceTest.java  |  5 +++--
 2 files changed, 13 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6d014860/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 7b640c5..1921fb1 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
@@ -244,19 +244,22 @@ public class BrooklynAssemblyTemplateInstantiator implements AssemblyTemplateSpe
 
             String catalogIdOrJavaType = entityResolver.getCatalogIdOrJavaType();
             CatalogItem<Entity, EntitySpec<?>> item = entityResolver.getCatalogItem();
-            
+
+            boolean firstOccurrence = encounteredCatalogTypes.add(catalogIdOrJavaType);
+            boolean recursiveButTryJava = !firstOccurrence;
+                         
             if (log.isTraceEnabled()) log.trace("Building CAMP template services: type="+catalogIdOrJavaType+";
item="+item+"; loader="+loader+"; template="+template+"; encounteredCatalogTypes="+encounteredCatalogTypes);
 
             EntitySpec<?> spec;
             if (item == null || item.getJavaType() != null || entityResolver.isJavaTypePrefix())
{
                 spec = entityResolver.resolveSpec();
-            } else {
-                boolean firstOccurrence = encounteredCatalogTypes.add(catalogIdOrJavaType);
-                if (firstOccurrence) {
-                    spec = resolveCatalogYamlReferenceSpec(platform, mgmt, item, encounteredCatalogTypes);
-                } else {
-                    throw new IllegalStateException("Recursive reference to " + catalogIdOrJavaType);
+            } else if (recursiveButTryJava) {
+                if (entityResolver.tryLoadEntityClass().isAbsent()) {
+                    throw new IllegalStateException("Recursive reference to " + catalogIdOrJavaType
+ " (and cannot be resolved as a Java type)");
                 }
+                spec = entityResolver.resolveSpec();
+            } else {
+                spec = resolveCatalogYamlReferenceSpec(platform, mgmt, item, encounteredCatalogTypes);
             }
 
             BrooklynClassLoadingContext newLoader = entityResolver.loader;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6d014860/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogBundleResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogBundleResourceTest.java
b/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogBundleResourceTest.java
index ba6e3ea..f9910dc 100644
--- a/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogBundleResourceTest.java
+++ b/usage/rest-server/src/test/java/brooklyn/rest/resources/CatalogBundleResourceTest.java
@@ -69,9 +69,10 @@ public class CatalogBundleResourceTest extends BrooklynRestResourceTest
{
     }
 
     @Test
-    public void testLaunchApplicationLoopWithJavaTypeNameInYamlFails() throws Exception {
+    public void testLaunchApplicationLoopWithJavaTypeNameInYaml() throws Exception {
         String registeredTypeName = SIMPLE_ENTITY_TYPE;
-        registerAndLaunchFailsWithRecursionError(registeredTypeName, registeredTypeName);
+        String serviceName = SIMPLE_ENTITY_TYPE;
+        registerAndLaunchAndAssertSimpleEntity(registeredTypeName, serviceName);
     }
 
     @Test


Mime
View raw message