brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [16/22] incubator-brooklyn git commit: add convenience method for creating spec from catalog item
Date Mon, 09 Feb 2015 15:36:35 GMT
add convenience method for creating spec from catalog item


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

Branch: refs/heads/master
Commit: 6156a7743bdeacadfd533ead28b4c7460fdc7610
Parents: 4582072
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Fri Feb 6 17:57:41 2015 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri Feb 6 22:12:14 2015 +0000

----------------------------------------------------------------------
 .../java/brooklyn/catalog/internal/CatalogUtils.java    | 10 ++++++++++
 .../management/osgi/OsgiVersionMoreEntityTest.java      | 12 +-----------
 2 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6156a774/core/src/main/java/brooklyn/catalog/internal/CatalogUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/catalog/internal/CatalogUtils.java b/core/src/main/java/brooklyn/catalog/internal/CatalogUtils.java
index ed4d06d..9741672 100644
--- a/core/src/main/java/brooklyn/catalog/internal/CatalogUtils.java
+++ b/core/src/main/java/brooklyn/catalog/internal/CatalogUtils.java
@@ -34,6 +34,7 @@ import brooklyn.catalog.internal.BasicBrooklynCatalog.BrooklynLoaderTracker;
 import brooklyn.config.BrooklynLogging;
 import brooklyn.entity.Entity;
 import brooklyn.entity.basic.EntityInternal;
+import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.entity.rebind.RebindManagerImpl.RebindTracker;
 import brooklyn.management.ManagementContext;
 import brooklyn.management.classloading.BrooklynClassLoadingContext;
@@ -227,4 +228,13 @@ public class CatalogUtils {
         }
     }
 
+    @Beta
+    public static EntitySpec<?> createEntitySpec(ManagementContext mgmt, CatalogItem<?,
?> catalogItem) {
+        BrooklynClassLoadingContext loader = CatalogUtils.newClassLoadingContext(mgmt, catalogItem);
+        @SuppressWarnings({ "unchecked", "rawtypes" })
+        EntitySpec<?> spec = EntitySpec.create( (Class)loader.loadClass(catalogItem.getJavaType())
);
+        spec.catalogItemId(catalogItem.getId());
+        return spec;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6156a774/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java b/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java
index 7bec58f..4e1bb94 100644
--- a/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java
+++ b/core/src/test/java/brooklyn/management/osgi/OsgiVersionMoreEntityTest.java
@@ -55,7 +55,6 @@ import brooklyn.util.guava.Maybe;
 import brooklyn.util.os.Os;
 import brooklyn.util.osgi.Osgis;
 
-import com.google.common.annotations.Beta;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
 
@@ -162,17 +161,8 @@ public class OsgiVersionMoreEntityTest {
         return addItemFromCatalog(mgmt, app, c2);
     }
     
-    @Beta
-    @SuppressWarnings({ "unchecked", "rawtypes" })
     public static Entity addItemFromCatalog(ManagementContext mgmt, TestApplication parent,
CatalogItem<?, ?> c2) {
-        BrooklynClassLoadingContext loader = CatalogUtils.newClassLoadingContext(mgmt, c2);
-        EntitySpec spec = EntitySpec.create( (Class)loader.loadClass(c2.getJavaType()) );
-        // not a great test as we set the ID here; but:
-        // YAML test will do better;
-        // and we can check that downstream items are loaded correctly
-        spec.catalogItemId(c2.getId());
-        Entity me = parent.createAndManageChild(spec);
-        return me;
+        return parent.createAndManageChild( CatalogUtils.createEntitySpec(mgmt, c2) );
     }
 
     public static void assertV1MethodCall(Entity me) throws IllegalAccessException, InvocationTargetException,
NoSuchMethodException {


Mime
View raw message