brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [5/9] incubator-brooklyn git commit: more converting CatalogItem access to RegisteredType
Date Mon, 02 Nov 2015 16:43:02 GMT
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/PoliciesYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/PoliciesYamlTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/PoliciesYamlTest.java
index 9648c51..6bcf49f 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/PoliciesYamlTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/PoliciesYamlTest.java
@@ -53,7 +53,7 @@ public class PoliciesYamlTest extends AbstractYamlTest {
         log.info("App started:");
         Entities.dumpInfo(app);
 
-        Assert.assertEquals(app.getPolicies().size(), 1);
+        Assert.assertEquals(app.policies().size(), 1);
         Policy policy = app.policies().iterator().next();
         Assert.assertTrue(policy instanceof TestPolicy);
         Assert.assertEquals(policy.getConfig(TestPolicy.CONF_NAME), "Name from YAML");
@@ -73,10 +73,10 @@ public class PoliciesYamlTest extends AbstractYamlTest {
         log.info("App started:");
         Entities.dumpInfo(app);
 
-        Assert.assertEquals(app.getPolicies().size(), 0);
+        Assert.assertEquals(app.policies().size(), 0);
         Assert.assertEquals(app.getChildren().size(), 1);
         Entity child = app.getChildren().iterator().next();
-        Assert.assertEquals(child.getPolicies().size(), 1);
+        Assert.assertEquals(child.policies().size(), 1);
         Policy policy = child.policies().iterator().next();
         Assert.assertNotNull(policy);
         Assert.assertTrue(policy instanceof TestPolicy, "policy=" + policy + "; type=" + policy.getClass());
@@ -108,13 +108,13 @@ public class PoliciesYamlTest extends AbstractYamlTest {
         final Entity child = firstEntity.getChildren().iterator().next();
         Assert.assertEquals(child.getChildren().size(), 0);
 
-        Assert.assertEquals(app.getPolicies().size(), 0);
-        Assert.assertEquals(firstEntity.getPolicies().size(), 0);
+        Assert.assertEquals(app.policies().size(), 0);
+        Assert.assertEquals(firstEntity.policies().size(), 0);
         
         Asserts.eventually(new Supplier<Integer>() {
             @Override
             public Integer get() {
-                return child.getPolicies().size();
+                return child.policies().size();
             }
         }, Predicates.<Integer> equalTo(1));
         
@@ -200,7 +200,7 @@ public class PoliciesYamlTest extends AbstractYamlTest {
     }
     
     private Policy getPolicy(Entity entity) {
-        Assert.assertEquals(entity.getPolicies().size(), 1);
+        Assert.assertEquals(entity.policies().size(), 1);
         Policy policy = entity.policies().iterator().next();
         Assert.assertTrue(policy instanceof TestReferencingPolicy);
         return policy;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/TestEntityWithInitConfig.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/TestEntityWithInitConfig.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/TestEntityWithInitConfig.java
index 98892c4..e5fb2f3 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/TestEntityWithInitConfig.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/TestEntityWithInitConfig.java
@@ -19,7 +19,6 @@
 package org.apache.brooklyn.camp.brooklyn;
 
 import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.entity.ImplementedBy;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.BasicConfigKey;
@@ -27,7 +26,7 @@ import org.apache.brooklyn.core.entity.EntityInternal;
 import org.apache.brooklyn.core.entity.trait.Startable;
 
 @ImplementedBy(TestEntityWithInitConfigImpl.class)
-public interface TestEntityWithInitConfig extends Entity, Startable, EntityLocal, EntityInternal {
+public interface TestEntityWithInitConfig extends Entity, Startable, EntityInternal {
     public static final ConfigKey<Entity> TEST_ENTITY = BasicConfigKey.builder(Entity.class)
             .name("test.entity")
             .build();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/TestSensorAndEffectorInitializer.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/TestSensorAndEffectorInitializer.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/TestSensorAndEffectorInitializer.java
index a73dd8d..91c18ed 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/TestSensorAndEffectorInitializer.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/TestSensorAndEffectorInitializer.java
@@ -42,7 +42,6 @@ public class TestSensorAndEffectorInitializer implements EntityInitializer {
 
     protected String helloWord() { return "Hello"; }
     
-    @Override
     public void apply(EntityLocal entity) {
         Effector<String> eff = Effectors.effector(String.class, EFFECTOR_SAY_HELLO).parameter(String.class, "name").impl(
             new EffectorBody<String>() {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/WindowsYamlLiveTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/WindowsYamlLiveTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/WindowsYamlLiveTest.java
index 15626db..a149f18 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/WindowsYamlLiveTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/WindowsYamlLiveTest.java
@@ -332,7 +332,7 @@ public class WindowsYamlLiveTest extends AbstractYamlTest {
             String taskNameRegex = entry.getKey();
             List<String> expectedOuts = entry.getValue();
 
-            Task<?> subTask = findTaskOrSubTask(tasks, TaskPredicates.displayNameMatches(StringPredicates.matchesRegex(taskNameRegex))).get();
+            Task<?> subTask = findTaskOrSubTask(tasks, TaskPredicates.displayNameSatisfies(StringPredicates.matchesRegex(taskNameRegex))).get();
 
             String stdin = getStreamOrFail(subTask, BrooklynTaskTags.STREAM_STDIN);
             String stdout = getStreamOrFail(subTask, BrooklynTaskTags.STREAM_STDOUT);
@@ -352,7 +352,7 @@ public class WindowsYamlLiveTest extends AbstractYamlTest {
         for (Map.Entry<String, Predicate<CharSequence>> entry : taskErrs.entrySet()) {
             String taskNameRegex = entry.getKey();
             Predicate<? super String> errChecker = entry.getValue();
-            Task<?> subTask = findTaskOrSubTask(tasks, TaskPredicates.displayNameMatches(StringPredicates.matchesRegex(taskNameRegex))).get();
+            Task<?> subTask = findTaskOrSubTask(tasks, TaskPredicates.displayNameSatisfies(StringPredicates.matchesRegex(taskNameRegex))).get();
             String msg = "regex="+taskNameRegex+"; task="+subTask;
             assertNotNull(subTask, msg);
             assertTrue(subTask.isDone(), msg);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityTest.java
index 2d7a117..c426897 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogOsgiVersionMoreEntityTest.java
@@ -20,26 +20,26 @@ package org.apache.brooklyn.camp.brooklyn.catalog;
 
 import static org.testng.Assert.assertTrue;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-import org.apache.brooklyn.api.catalog.BrooklynCatalog;
-import org.apache.brooklyn.api.catalog.CatalogItem;
-import org.apache.brooklyn.api.catalog.CatalogItem.CatalogItemType;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.api.policy.Policy;
 import org.apache.brooklyn.api.policy.PolicySpec;
+import org.apache.brooklyn.api.typereg.BrooklynTypeRegistry;
+import org.apache.brooklyn.api.typereg.RegisteredType;
 import org.apache.brooklyn.camp.brooklyn.AbstractYamlTest;
 import org.apache.brooklyn.camp.brooklyn.spi.creation.BrooklynEntityMatcher;
-import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
 import org.apache.brooklyn.core.mgmt.osgi.OsgiVersionMoreEntityTest;
 import org.apache.brooklyn.core.objs.BrooklynTypes;
+import org.apache.brooklyn.core.typereg.RegisteredTypePredicates;
 import org.apache.brooklyn.test.support.TestResourceUnavailableException;
 import org.apache.brooklyn.util.core.ResourceUtils;
 import org.apache.brooklyn.util.text.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+import org.testng.annotations.Test;
 
 import com.google.common.collect.Iterables;
 
@@ -58,10 +58,10 @@ public class CatalogOsgiVersionMoreEntityTest extends AbstractYamlTest {
         TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), "/brooklyn/osgi/brooklyn-test-osgi-more-entities_0.1.0.jar");
 
         addCatalogItems(getLocalResource("more-entity-v1-osgi-catalog.yaml"));
-        CatalogItem<?, ?> item = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), "more-entity");
+        RegisteredType item = mgmt().getTypeRegistry().get("more-entity");
         Assert.assertNotNull(item);
         Assert.assertEquals(item.getVersion(), "1.0");
-        Assert.assertEquals(item.getCatalogItemType(), CatalogItemType.ENTITY);
+        Assert.assertTrue(RegisteredTypePredicates.IS_ENTITY.apply(item));
         Assert.assertEquals(item.getLibraries().size(), 1);
         
         Entity app = createAndStartApplication("services: [ { type: 'more-entity:1.0' } ]");
@@ -86,7 +86,7 @@ public class CatalogOsgiVersionMoreEntityTest extends AbstractYamlTest {
         
         Assert.assertEquals(moreEntity.getCatalogItemId(), "more-entity:1.0");
         
-        Assert.assertEquals(moreEntity.getPolicies().size(), 1, "wrong policies: "+moreEntity.getPolicies());
+        Assert.assertEquals(moreEntity.policies().size(), 1, "wrong policies: "+moreEntity.policies());
         Policy policy = Iterables.getOnlyElement(moreEntity.policies());
         // it was loaded by yaml w ref to catalog, so should have the simple-policy catalog-id
         Assert.assertEquals(policy.getCatalogItemId(), "simple-policy:1.0");
@@ -105,7 +105,7 @@ public class CatalogOsgiVersionMoreEntityTest extends AbstractYamlTest {
         OsgiVersionMoreEntityTest.assertV2EffectorCall(moreEntity);
         OsgiVersionMoreEntityTest.assertV2MethodCall(moreEntity);
         
-        Assert.assertEquals(moreEntity.getPolicies().size(), 1, "wrong policies: "+moreEntity.getPolicies());
+        Assert.assertEquals(moreEntity.policies().size(), 1, "wrong policies: "+moreEntity.policies());
         Policy policy = Iterables.getOnlyElement(moreEntity.policies());
         // it was loaded from the java so should have the base more-entity catalog id
         Assert.assertEquals(policy.getCatalogItemId(), "more-entity:1.0");
@@ -177,13 +177,13 @@ public class CatalogOsgiVersionMoreEntityTest extends AbstractYamlTest {
         
         log.info("autoscan for osgi found catalog items: "+Strings.join(mgmt().getCatalog().getCatalogItems(), ", "));
 
-        CatalogItem<?, ?> item = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), "more-entity");
+        RegisteredType item = mgmt().getTypeRegistry().get("more-entity");
         Assert.assertNotNull(item);
         Assert.assertEquals(item.getVersion(), "2.0.test");
-        Assert.assertEquals(item.getCatalogItemType(), CatalogItemType.ENTITY);
+        Assert.assertTrue(RegisteredTypePredicates.IS_ENTITY.apply(item));
         
         // this refers to the java item, where the libraries are defined
-        item = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), "org.apache.brooklyn.test.osgi.entities.more.MoreEntity");
+        item = mgmt().getTypeRegistry().get("org.apache.brooklyn.test.osgi.entities.more.MoreEntity");
         Assert.assertEquals(item.getVersion(), "2.0.test_java");
         Assert.assertEquals(item.getLibraries().size(), 2);
         
@@ -204,13 +204,13 @@ public class CatalogOsgiVersionMoreEntityTest extends AbstractYamlTest {
         
         log.info("autoscan for osgi found catalog items: "+Strings.join(mgmt().getCatalog().getCatalogItems(), ", "));
 
-        CatalogItem<?, ?> item = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), "more-policy");
+        RegisteredType item = mgmt().getTypeRegistry().get("more-policy");
         Assert.assertNotNull(item);
         Assert.assertEquals(item.getVersion(), "2.0.test");
-        Assert.assertEquals(item.getCatalogItemType(), CatalogItemType.POLICY);
+        Assert.assertTrue(RegisteredTypePredicates.IS_POLICY.apply(item));
         
         // this refers to the java item, where the libraries are defined
-        item = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), "org.apache.brooklyn.test.osgi.entities.more.MorePolicy");
+        item = mgmt().getTypeRegistry().get("org.apache.brooklyn.test.osgi.entities.more.MorePolicy");
         Assert.assertEquals(item.getVersion(), "2.0.test_java");
         Assert.assertEquals(item.getLibraries().size(), 2);
         
@@ -233,27 +233,23 @@ public class CatalogOsgiVersionMoreEntityTest extends AbstractYamlTest {
 
         addCatalogItems(getLocalResource("more-entities-osgi-catalog-scan.yaml"));
 
-        log.info("autoscan for osgi found catalog items: "+Strings.join(mgmt().getCatalog().getCatalogItems(), ", "));
+        log.info("autoscan for osgi found catalog items: "+Strings.join(mgmt().getTypeRegistry().getAll(), ", "));
 
-        BrooklynCatalog catalog = mgmt().getCatalog();
-        Iterable<CatalogItem<Object, Object>> items = catalog.getCatalogItems();
-        for (CatalogItem<Object, Object> item: items) {
-            @SuppressWarnings({ "unchecked", "rawtypes" })
-            Object spec = catalog.createSpec((CatalogItem)item);
-            switch (item.getCatalogItemType()) {
-                case TEMPLATE:
-                case ENTITY:
-                    assertTrue(spec instanceof EntitySpec, "Not an EntitySpec: " + spec);
-                    BrooklynTypes.getDefinedEntityType(((EntitySpec<?>)spec).getType());
-                    break;
-                case POLICY:
-                    assertTrue(spec instanceof PolicySpec, "Not a PolicySpec: " + spec);
-                    BrooklynTypes.getDefinedBrooklynType(((PolicySpec<?>)spec).getType());
-                    break;
-                case LOCATION:
-                    assertTrue(spec instanceof LocationSpec, "Not a LocationSpec: " + spec);
-                    BrooklynTypes.getDefinedBrooklynType(((LocationSpec<?>)spec).getType());
-                    break;
+        BrooklynTypeRegistry types = mgmt().getTypeRegistry();
+        Iterable<RegisteredType> items = types.getAll();
+        for (RegisteredType item: items) {
+            Object spec = types.createSpec(item, null, null);
+            if (Entity.class.isAssignableFrom(item.getJavaType())) {
+                assertTrue(spec instanceof EntitySpec, "Not an EntitySpec: " + spec);
+                BrooklynTypes.getDefinedEntityType(((EntitySpec<?>)spec).getType());
+            } else if (Policy.class.isAssignableFrom(item.getJavaType())) { 
+                assertTrue(spec instanceof PolicySpec, "Not a PolicySpec: " + spec);
+                BrooklynTypes.getDefinedBrooklynType(((PolicySpec<?>)spec).getType());
+            } else if (Location.class.isAssignableFrom(item.getJavaType())) {
+                assertTrue(spec instanceof LocationSpec, "Not a LocationSpec: " + spec);
+                BrooklynTypes.getDefinedBrooklynType(((LocationSpec<?>)spec).getType());
+            } else {
+                Assert.fail("Unexpected type: "+item.getJavaType()+" / "+item);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlOsgiTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlOsgiTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlOsgiTest.java
index 5a2362e..2161fec 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlOsgiTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogXmlOsgiTest.java
@@ -18,11 +18,6 @@
  */
 package org.apache.brooklyn.camp.brooklyn.catalog;
 
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
-
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.exceptions.PropagatedRuntimeException;
 import org.testng.annotations.Test;
 
 public class CatalogXmlOsgiTest extends AbstractCatalogXmlTest {
@@ -31,19 +26,12 @@ public class CatalogXmlOsgiTest extends AbstractCatalogXmlTest {
         super("classpath://osgi-catalog.xml");
     }
 
-    //OSGi libraries not supported with old-style catalog items
-    //We treat those catalog items just as an alias to the java type they hold.
-    //No loader wrapping their libraries is ever created.
     @Test
     public void testOsgiItem() throws Exception {
-        try {
-            startApp("OsgiApp");
-            fail();
-        } catch (PropagatedRuntimeException e) {
-            ClassNotFoundException ex = Exceptions.getFirstThrowableOfType(e, ClassNotFoundException.class);
-            if (ex == null) throw e;
-            assertEquals(ex.getMessage(), "org.apache.brooklyn.test.osgi.entities.SimpleApplication");
-        }
+        startApp("OsgiApp");
+        // previously OSGi libraries were not supported with old-style catalog items;
+        // now they are (2015-10), even though the XML is not supported,
+        // we may use the same type instantiator from CAMP and elsewhere
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlCombiTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlCombiTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlCombiTest.java
index 8e10c20..8ce0023 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlCombiTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlCombiTest.java
@@ -60,7 +60,7 @@ public class CatalogYamlCombiTest extends AbstractYamlTest {
             "      type: A",
             "      brooklyn.config: { b: 1 }");
 
-        RegisteredType item = mgmt().getTypeRegistry().get("B", TEST_VERSION, null, null);
+        RegisteredType item = mgmt().getTypeRegistry().get("B", TEST_VERSION);
         Assert.assertNotNull(item);
 
         Entity a = launchEntity("A");
@@ -113,7 +113,7 @@ public class CatalogYamlCombiTest extends AbstractYamlTest {
             "      brooklyn.policies:",
             "      - type: A");
 
-        RegisteredType item = mgmt().getTypeRegistry().get("A", TEST_VERSION, null, null);
+        RegisteredType item = mgmt().getTypeRegistry().get("A", TEST_VERSION);
         Assert.assertNotNull(item);
 
         Entity b = launchEntity("B", false);
@@ -122,7 +122,7 @@ public class CatalogYamlCombiTest extends AbstractYamlTest {
         
         Assert.assertEquals(Iterables.getOnlyElement(b.getLocations()).getConfig(ConfigKeys.newIntegerConfigKey("z")), (Integer)9);
         
-        Policy p = Iterables.getOnlyElement(b.getPolicies());
+        Policy p = Iterables.getOnlyElement(b.policies());
         Assert.assertTrue(ServiceRestarter.class.isInstance(p), "Wrong type: "+p);
         Assert.assertEquals(p.getConfig(ConfigKeys.newIntegerConfigKey("a")), (Integer)99);
         

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
index 882332b..247f6b4 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlEntityTest.java
@@ -531,9 +531,9 @@ public class CatalogYamlEntityTest extends AbstractYamlTest {
         addCatalogOSGiEntity(id);
         BrooklynTypeRegistry catalog = mgmt().getTypeRegistry();
         RegisteredType item = catalog.get(id, TEST_VERSION);
-        EntitySpec<?> spec = catalog.createSpec(item, EntitySpec.class);
+        EntitySpec<?> spec = catalog.createSpec(item, null, EntitySpec.class);
         Assert.assertNotNull(spec);
-        AbstractBrooklynObjectSpec<?,?> spec2 = catalog.createSpec(item, AbstractBrooklynObjectSpec.class);
+        AbstractBrooklynObjectSpec<?,?> spec2 = catalog.createSpec(item, null, null);
         Assert.assertNotNull(spec2);
     }
     
@@ -613,7 +613,7 @@ public class CatalogYamlEntityTest extends AbstractYamlTest {
                 "  version: " + TEST_VERSION + "pre",
                 "",
                 "services:",
-                "- type: org.apache.brooklyn.entity.stock.BasicEntity");
+                "- type: "+BasicEntity.class.getName());
 
         addCatalogItems(
                 "brooklyn.catalog:",

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlLocationTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlLocationTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlLocationTest.java
index eebaea5..e13792d 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlLocationTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlLocationTest.java
@@ -118,7 +118,7 @@ public class CatalogYamlLocationTest extends AbstractYamlTest {
         assertEquals(def.getId(), symbolicName);
         assertEquals(def.getName(), symbolicName);
         
-        LocationSpec spec = (LocationSpec) mgmt().getTypeRegistry().createSpec(item, LocationSpec.class);
+        LocationSpec spec = (LocationSpec) mgmt().getTypeRegistry().createSpec(item, null, LocationSpec.class);
         assertEquals(spec.getType().getName(), expectedJavaType);
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlPolicyTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlPolicyTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlPolicyTest.java
index 062cb47..fbfe630 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlPolicyTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlPolicyTest.java
@@ -20,15 +20,15 @@ package org.apache.brooklyn.camp.brooklyn.catalog;
 
 import static org.testng.Assert.assertEquals;
 
-import org.testng.annotations.Test;
-import org.apache.brooklyn.api.catalog.CatalogItem;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.policy.Policy;
+import org.apache.brooklyn.api.typereg.RegisteredType;
 import org.apache.brooklyn.camp.brooklyn.AbstractYamlTest;
 import org.apache.brooklyn.core.catalog.CatalogPredicates;
 import org.apache.brooklyn.core.config.BasicConfigKey;
 import org.apache.brooklyn.core.mgmt.osgi.OsgiStandaloneTest;
 import org.apache.brooklyn.test.support.TestResourceUnavailableException;
+import org.testng.annotations.Test;
 
 import com.google.common.collect.Iterables;
 
@@ -43,7 +43,7 @@ public class CatalogYamlPolicyTest extends AbstractYamlTest {
         String symbolicName = "my.catalog.policy.id.load";
         addCatalogOsgiPolicy(symbolicName, SIMPLE_POLICY_TYPE);
 
-        CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem(symbolicName, TEST_VERSION);
+        RegisteredType item = mgmt().getTypeRegistry().get(symbolicName, TEST_VERSION);
         assertEquals(item.getSymbolicName(), symbolicName);
         assertEquals(countCatalogPolicies(), 1);
 
@@ -57,7 +57,7 @@ public class CatalogYamlPolicyTest extends AbstractYamlTest {
         String symbolicName = "my.catalog.policy.id.load";
         addCatalogOsgiPolicyTopLevelSyntax(symbolicName, SIMPLE_POLICY_TYPE);
 
-        CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem(symbolicName, TEST_VERSION);
+        RegisteredType item = mgmt().getTypeRegistry().get(symbolicName, TEST_VERSION);
         assertEquals(item.getSymbolicName(), symbolicName);
         assertEquals(countCatalogPolicies(), 1);
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java
index 67ef06c..2996685 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlRebindTest.java
@@ -21,8 +21,8 @@ package org.apache.brooklyn.camp.brooklyn.catalog;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
@@ -41,6 +41,7 @@ import org.apache.brooklyn.api.catalog.CatalogItem;
 import org.apache.brooklyn.api.mgmt.rebind.mementos.BrooklynMementoPersister;
 import org.apache.brooklyn.api.policy.Policy;
 import org.apache.brooklyn.api.sensor.Enricher;
+import org.apache.brooklyn.api.typereg.RegisteredType;
 import org.apache.brooklyn.camp.brooklyn.AbstractYamlRebindTest;
 import org.apache.brooklyn.core.BrooklynFeatureEnablement;
 import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
@@ -125,7 +126,7 @@ public class CatalogYamlRebindTest extends AbstractYamlRebindTest {
         runRebindWithCatalogAndApp(RebindWithCatalogTestMode.STRIP_DEPRECATION_AND_ENABLEMENT_FROM_CATALOG_ITEM);
     }
 
-    @SuppressWarnings("unused")
+    @SuppressWarnings({ "unused", "deprecation" })
     protected void runRebindWithCatalogAndApp(RebindWithCatalogTestMode mode) throws Exception {
         String appSymbolicName = "my.catalog.app.id.load";
         String appVersion = "0.1.0";
@@ -170,20 +171,12 @@ public class CatalogYamlRebindTest extends AbstractYamlRebindTest {
         // Depending on test-mode, delete the catalog item, and then rebind
         switch (mode) {
             case DEPRECATE_CATALOG:
-                appItem = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), appSymbolicName+":"+appVersion);
-                appItem.setDeprecated(true);
-                mgmt().getCatalog().persist(appItem);
-                locItem = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), locSymbolicName+":"+locVersion);
-                locItem.setDeprecated(true);
-                mgmt().getCatalog().persist(locItem);
+                CatalogUtils.setDeprecated(mgmt(), appSymbolicName, appVersion, true);
+                CatalogUtils.setDeprecated(mgmt(), locSymbolicName, locVersion, true);
                 break;
             case DISABLE_CATALOG:
-                appItem = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), appSymbolicName+":"+appVersion);
-                appItem.setDisabled(true);
-                mgmt().getCatalog().persist(appItem);
-                locItem = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), locSymbolicName+":"+locVersion);
-                locItem.setDisabled(true);
-                mgmt().getCatalog().persist(locItem);
+                CatalogUtils.setDisabled(mgmt(), appSymbolicName, appVersion, true);
+                CatalogUtils.setDisabled(mgmt(), locSymbolicName, locVersion, true);
                 break;
             case DELETE_CATALOG:
                 mgmt().getCatalog().deleteCatalogItem(appSymbolicName, appVersion);
@@ -198,13 +191,7 @@ public class CatalogYamlRebindTest extends AbstractYamlRebindTest {
                 addCatalogItems(String.format(locCatalogFormat, locVersion));
                 break;
             case STRIP_DEPRECATION_AND_ENABLEMENT_FROM_CATALOG_ITEM:
-                //Make sure that the flags are actually removed from the XML instead of still being there with false values
-                appItem.setDeprecated(true);
-                appItem.setDisabled(true);
-                mgmt().getCatalog().persist(appItem);
-                locItem.setDisabled(true);
-                locItem.setDeprecated(true);
-                mgmt().getCatalog().persist(locItem);
+                // nothing here -- but below we rebind with these fields removed to ensure that we can rebind
                 break;
             case NO_OP:
                 break; // no-op
@@ -244,8 +231,8 @@ public class CatalogYamlRebindTest extends AbstractYamlRebindTest {
         assertFalse(Entities.isManaged(newEntity));
         
         // Ensure catalog item is as expecpted
-        CatalogItem<?, ?> newAppItem = mgmt().getCatalog().getCatalogItem(appSymbolicName, appVersion);
-        CatalogItem<?, ?> newLocItem = mgmt().getCatalog().getCatalogItem(locSymbolicName, locVersion);
+        RegisteredType newAppItem = mgmt().getTypeRegistry().get(appSymbolicName, appVersion);
+        RegisteredType newLocItem = mgmt().getTypeRegistry().get(locSymbolicName, locVersion);
 
         boolean itemDeployable;
         switch (mode) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java
index bc55be9..c3dbc48 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlTemplateTest.java
@@ -18,18 +18,17 @@
  */
 package org.apache.brooklyn.camp.brooklyn.catalog;
 
-import static org.testng.Assert.assertEquals;
-
+import org.apache.brooklyn.api.typereg.RegisteredType;
+import org.apache.brooklyn.camp.brooklyn.AbstractYamlTest;
+import org.apache.brooklyn.core.mgmt.osgi.OsgiStandaloneTest;
+import org.apache.brooklyn.core.typereg.RegisteredTypePredicates;
+import org.apache.brooklyn.core.typereg.RegisteredTypes;
+import org.apache.brooklyn.test.support.TestResourceUnavailableException;
+import org.apache.brooklyn.util.osgi.OsgiTestResources;
 import org.testng.Assert;
 import org.testng.TestListenerAdapter;
 import org.testng.TestNG;
 import org.testng.annotations.Test;
-import org.apache.brooklyn.api.catalog.CatalogItem;
-import org.apache.brooklyn.api.catalog.CatalogItem.CatalogItemType;
-import org.apache.brooklyn.camp.brooklyn.AbstractYamlTest;
-import org.apache.brooklyn.core.mgmt.osgi.OsgiStandaloneTest;
-import org.apache.brooklyn.util.osgi.OsgiTestResources;
-import org.apache.brooklyn.test.support.TestResourceUnavailableException;
 
 
 public class CatalogYamlTemplateTest extends AbstractYamlTest {
@@ -38,12 +37,13 @@ public class CatalogYamlTemplateTest extends AbstractYamlTest {
 
     @Test
     public void testAddCatalogItem() throws Exception {
-        CatalogItem<?, ?> item = makeItem();
-        assertEquals(item.getCatalogItemType(), CatalogItemType.TEMPLATE);
-        Assert.assertTrue(item.getPlanYaml().indexOf("sample comment")>=0,
-            "YAML did not include original comments; it was:\n"+item.getPlanYaml());
-        Assert.assertFalse(item.getPlanYaml().indexOf("description")>=0,
-            "YAML included metadata which should have been excluded; it was:\n"+item.getPlanYaml());
+        RegisteredType item = makeItem();
+        Assert.assertTrue(RegisteredTypePredicates.IS_APPLICATION.apply(item), "item: "+item);
+        String yaml = RegisteredTypes.getImplementationDataStringForSpec(item);
+        Assert.assertTrue(yaml.indexOf("sample comment")>=0,
+            "YAML did not include original comments; it was:\n"+yaml);
+        Assert.assertFalse(yaml.indexOf("description")>=0,
+            "YAML included metadata which should have been excluded; it was:\n"+yaml);
 
         deleteCatalogEntity("t1");
     }
@@ -53,16 +53,17 @@ public class CatalogYamlTemplateTest extends AbstractYamlTest {
         // this will fail with the Eclipse TestNG plugin -- use the static main instead to run in eclipse!
         // see Yamls.KnownClassVersionException for details
         
-        CatalogItem<?, ?> item = makeItem();
-        Assert.assertTrue(item.getPlanYaml().indexOf("sample comment")>=0,
-            "YAML did not include original comments; it was:\n"+item.getPlanYaml());
-        Assert.assertFalse(item.getPlanYaml().indexOf("description")>=0,
-            "YAML included metadata which should have been excluded; it was:\n"+item.getPlanYaml());
+        RegisteredType item = makeItem();
+        String yaml = RegisteredTypes.getImplementationDataStringForSpec(item);
+        Assert.assertTrue(yaml.indexOf("sample comment")>=0,
+            "YAML did not include original comments; it was:\n"+yaml);
+        Assert.assertFalse(yaml.indexOf("description")>=0,
+            "YAML included metadata which should have been excluded; it was:\n"+yaml);
 
         deleteCatalogEntity("t1");
     }
 
-    private CatalogItem<?, ?> makeItem() {
+    private RegisteredType makeItem() {
         TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), OsgiStandaloneTest.BROOKLYN_TEST_OSGI_ENTITIES_PATH);
         
         addCatalogItems(
@@ -80,8 +81,7 @@ public class CatalogYamlTemplateTest extends AbstractYamlTest {
             "    # this sample comment should be included",
             "    - type: " + SIMPLE_ENTITY_TYPE);
 
-        CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem("t1", TEST_VERSION);
-        return item;
+        return mgmt().getTypeRegistry().get("t1", TEST_VERSION);
     }
 
     // convenience for running in eclipse when the TestNG plugin drags in old version of snake yaml

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlVersioningTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlVersioningTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlVersioningTest.java
index 68f73a8..f92f3a4 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlVersioningTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/catalog/CatalogYamlVersioningTest.java
@@ -23,30 +23,31 @@ import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.apache.brooklyn.api.catalog.BrooklynCatalog;
-import org.apache.brooklyn.api.catalog.CatalogItem;
 import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.typereg.BrooklynTypeRegistry;
+import org.apache.brooklyn.api.typereg.RegisteredType;
 import org.apache.brooklyn.camp.brooklyn.AbstractYamlTest;
-import org.apache.brooklyn.core.catalog.CatalogPredicates;
 import org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog;
 import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.typereg.RegisteredTypePredicates;
+import org.apache.brooklyn.core.typereg.RegisteredTypes;
 import org.apache.brooklyn.entity.stock.BasicApplication;
 import org.apache.brooklyn.entity.stock.BasicEntity;
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
 
 import com.google.common.base.Predicates;
 import com.google.common.collect.Iterables;
 
 public class CatalogYamlVersioningTest extends AbstractYamlTest {
     
-    private BrooklynCatalog catalog;
+    private BrooklynTypeRegistry types;
     
     @BeforeMethod(alwaysRun = true)
     public void setUp() {
         super.setUp();
-        catalog = mgmt().getCatalog();
+        types = mgmt().getTypeRegistry();
     }
 
     @Test
@@ -86,8 +87,9 @@ public class CatalogYamlVersioningTest extends AbstractYamlTest {
         forceCatalogUpdate();
         String expectedType = "org.apache.brooklyn.entity.stock.BasicApplication";
         addCatalogEntity(symbolicName, version, expectedType);
-        CatalogItem<?, ?> item = catalog.getCatalogItem(symbolicName, version);
-        assertTrue(item.getPlanYaml().contains(expectedType), "Version not updated");
+        RegisteredType item = types.get(symbolicName, version);
+        String yaml = RegisteredTypes.getImplementationDataStringForSpec(item);
+        assertTrue(yaml.contains(expectedType), "Version not updated:\n"+yaml);
     }
     
     @Test
@@ -97,7 +99,7 @@ public class CatalogYamlVersioningTest extends AbstractYamlTest {
         String v2 = "0.2.0";
         addCatalogEntity(symbolicName, v1);
         addCatalogEntity(symbolicName, v2);
-        CatalogItem<?, ?> item = catalog.getCatalogItem(symbolicName, BasicBrooklynCatalog.DEFAULT_VERSION);
+        RegisteredType item = types.get(symbolicName, BasicBrooklynCatalog.DEFAULT_VERSION);
         assertEquals(item.getVersion(), v2);
     }
     
@@ -108,7 +110,7 @@ public class CatalogYamlVersioningTest extends AbstractYamlTest {
         String v2 = "0.2.0-SNAPSHOT";
         addCatalogEntity(symbolicName, v1);
         addCatalogEntity(symbolicName, v2);
-        CatalogItem<?, ?> item = catalog.getCatalogItem(symbolicName, BasicBrooklynCatalog.DEFAULT_VERSION);
+        RegisteredType item = types.get(symbolicName, BasicBrooklynCatalog.DEFAULT_VERSION);
         assertEquals(item.getVersion(), v1);
     }
 
@@ -117,18 +119,28 @@ public class CatalogYamlVersioningTest extends AbstractYamlTest {
         String symbolicName = "sampleId";
         String version = "0.1.0";
         addCatalogEntity(symbolicName, version);
-        assertTrue(catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo(symbolicName))).iterator().hasNext());
-        catalog.deleteCatalogItem(symbolicName, version);
-        assertFalse(catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo(symbolicName))).iterator().hasNext());
+        
+        Iterable<RegisteredType> matches;
+        matches = types.getAll(RegisteredTypePredicates.symbolicName(Predicates.equalTo(symbolicName)));
+        assertTrue(matches.iterator().hasNext());
+        
+        mgmt().getCatalog().deleteCatalogItem(symbolicName, version);
+        matches = types.getAll(RegisteredTypePredicates.symbolicName(Predicates.equalTo(symbolicName)));
+        assertFalse(matches.iterator().hasNext());
     }
     
     @Test
     public void testDeleteDefault() {
         String symbolicName = "sampleId";
         addCatalogEntity(symbolicName, null);
-        assertTrue(catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo(symbolicName))).iterator().hasNext());
-        catalog.deleteCatalogItem(symbolicName, BasicBrooklynCatalog.NO_VERSION);
-        assertFalse(catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo(symbolicName))).iterator().hasNext());
+
+        Iterable<RegisteredType> matches;
+        matches = types.getAll(RegisteredTypePredicates.symbolicName(Predicates.equalTo(symbolicName)));
+        assertTrue(matches.iterator().hasNext());
+        
+        mgmt().getCatalog().deleteCatalogItem(symbolicName, BasicBrooklynCatalog.NO_VERSION);
+        matches = types.getAll(RegisteredTypePredicates.symbolicName(Predicates.equalTo(symbolicName)));
+        assertFalse(matches.iterator().hasNext());
     }
     
     @Test
@@ -138,7 +150,7 @@ public class CatalogYamlVersioningTest extends AbstractYamlTest {
         String v2 = "0.2.0-SNAPSHOT";
         addCatalogEntity(symbolicName, v1);
         addCatalogEntity(symbolicName, v2);
-        Iterable<CatalogItem<Object, Object>> items = catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo(symbolicName)));
+        Iterable<RegisteredType> items = types.getAll(RegisteredTypePredicates.symbolicName(Predicates.equalTo(symbolicName)));
         assertEquals(Iterables.size(items), 2);
     }
     
@@ -200,9 +212,9 @@ public class CatalogYamlVersioningTest extends AbstractYamlTest {
                 "      type: referrent\n" +
                 "      version: 1.1"));
         
-        Iterable<CatalogItem<Object, Object>> items = catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo("referrer")));
+        Iterable<RegisteredType> items = types.getAll(RegisteredTypePredicates.symbolicName(Predicates.equalTo("referrer")));
         Assert.assertEquals(Iterables.size(items), 1, "Wrong number of: "+items);
-        CatalogItem<Object, Object> item = Iterables.getOnlyElement(items);
+        RegisteredType item = Iterables.getOnlyElement(items);
         Assert.assertEquals(item.getVersion(), "1.0");
         
         Entity app = createAndStartApplication(
@@ -227,8 +239,8 @@ public class CatalogYamlVersioningTest extends AbstractYamlTest {
     }
     
     private void assertSingleCatalogItem(String symbolicName, String version) {
-        Iterable<CatalogItem<Object, Object>> items = catalog.getCatalogItems(CatalogPredicates.symbolicName(Predicates.equalTo(symbolicName)));
-        CatalogItem<Object, Object> item = Iterables.getOnlyElement(items);
+        Iterable<RegisteredType> items = types.getAll(RegisteredTypePredicates.symbolicName(Predicates.equalTo(symbolicName)));
+        RegisteredType item = Iterables.getOnlyElement(items);
         assertEquals(item.getSymbolicName(), symbolicName);
         assertEquals(item.getVersion(), version);
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/test/lite/CampYamlLiteTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/test/lite/CampYamlLiteTest.java b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/test/lite/CampYamlLiteTest.java
index 9f2a377..cb0b169 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/test/lite/CampYamlLiteTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/test/lite/CampYamlLiteTest.java
@@ -30,6 +30,7 @@ import java.util.Map;
 
 import org.apache.brooklyn.api.catalog.CatalogItem;
 import org.apache.brooklyn.api.catalog.CatalogItem.CatalogBundle;
+import org.apache.brooklyn.api.entity.Application;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.mgmt.Task;
@@ -53,6 +54,7 @@ import org.apache.brooklyn.core.mgmt.osgi.OsgiStandaloneTest;
 import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
 import org.apache.brooklyn.core.test.entity.TestApplication;
 import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.apache.brooklyn.core.typereg.RegisteredTypeConstraints;
 import org.apache.brooklyn.core.typereg.RegisteredTypes;
 import org.apache.brooklyn.test.support.TestResourceUnavailableException;
 import org.apache.brooklyn.util.collections.MutableMap;
@@ -230,7 +232,7 @@ public class CampYamlLiteTest {
     }
 
     private void assertMgmtHasSampleMyCatalogApp(String symbolicName, String bundleUrl) {
-        RegisteredType item = mgmt.getTypeRegistry().get(symbolicName, BrooklynTypeRegistry.RegisteredTypeKind.SPEC, null);
+        RegisteredType item = mgmt.getTypeRegistry().get(symbolicName, RegisteredTypeConstraints.spec(Entity.class));
         assertNotNull(item, "failed to load item with id=" + symbolicName + " from catalog. Entries were: " +
                 Joiner.on(",").join(mgmt.getTypeRegistry().getAll()));
         assertEquals(item.getSymbolicName(), symbolicName);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/BrooklynWebConfig.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/BrooklynWebConfig.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/BrooklynWebConfig.java
index c2aaebd..601ff71 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/BrooklynWebConfig.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/BrooklynWebConfig.java
@@ -152,7 +152,7 @@ public class BrooklynWebConfig {
             "SSL_RSA_WITH_3DES_EDE_CBC_SHA");
 
     public final static boolean hasNoSecurityOptions(ConfigMap config) {
-        return config.submap(ConfigPredicates.startingWith(BASE_NAME_SECURITY)).isEmpty();
+        return config.submap(ConfigPredicates.nameStartsWith(BASE_NAME_SECURITY)).isEmpty();
     }
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/AbstractBrooklynRestResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/AbstractBrooklynRestResource.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/AbstractBrooklynRestResource.java
index a07e684..e4dacc9 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/AbstractBrooklynRestResource.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/AbstractBrooklynRestResource.java
@@ -23,7 +23,6 @@ import javax.servlet.ServletContext;
 import javax.ws.rs.core.Context;
 
 import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.core.config.render.RendererHints;
 import org.apache.brooklyn.core.mgmt.ManagementContextInjectable;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
index c8c004c..699c860 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ApplicationResource.java
@@ -42,9 +42,10 @@ import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.entity.Group;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.api.objs.BrooklynObject;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.api.sensor.Sensor;
-import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
+import org.apache.brooklyn.api.typereg.BrooklynTypeRegistry.RegisteredTypeKind;
 import org.apache.brooklyn.core.config.ConstraintViolationException;
 import org.apache.brooklyn.core.entity.Attributes;
 import org.apache.brooklyn.core.entity.EntityPredicates;
@@ -57,6 +58,7 @@ import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements.EntityAndItem;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements.StringAndArgument;
 import org.apache.brooklyn.core.sensor.Sensors;
+import org.apache.brooklyn.core.typereg.RegisteredTypeConstraints;
 import org.apache.brooklyn.entity.group.AbstractGroup;
 import org.apache.brooklyn.rest.api.ApplicationApi;
 import org.apache.brooklyn.rest.domain.ApplicationSpec;
@@ -73,6 +75,7 @@ import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.core.ResourceUtils;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.exceptions.UserFacingException;
+import org.apache.brooklyn.util.javalang.JavaClassNames;
 import org.apache.brooklyn.util.text.Strings;
 import org.codehaus.jackson.JsonNode;
 import org.codehaus.jackson.node.ArrayNode;
@@ -144,8 +147,8 @@ public class ApplicationResource extends AbstractBrooklynRestResource implements
             aRoot.put("parentId", entity.getParent().getId());
         }
 
-        if (!entity.getGroups().isEmpty())
-            aRoot.put("groupIds", entitiesIdAsArray(entity.getGroups()));
+        if (!entity.groups().isEmpty())
+            aRoot.put("groupIds", entitiesIdAsArray(entity.groups()));
 
         if (!entity.getChildren().isEmpty())
             aRoot.put("children", entitiesIdAndNameAsArray(entity.getChildren()));
@@ -183,7 +186,7 @@ public class ApplicationResource extends AbstractBrooklynRestResource implements
         return node;
     }
 
-    private ArrayNode entitiesIdAsArray(Collection<? extends Entity> entities) {
+    private ArrayNode entitiesIdAsArray(Iterable<? extends Entity> entities) {
         ArrayNode node = mapper().createArrayNode();
         for (Entity entity : entities) {
             if (Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.SEE_ENTITY, entity)) {
@@ -398,17 +401,21 @@ public class ApplicationResource extends AbstractBrooklynRestResource implements
         }
     }
 
-    private void checkEntityTypeIsValid(String type) {
-        if (CatalogUtils.getCatalogItemOptionalVersion(mgmt(), type) == null) {
+    private void checkSpecTypeIsValid(String type, Class<? extends BrooklynObject> subType) {
+        if (mgmt().getTypeRegistry().get(type, RegisteredTypeConstraints.spec(subType)) == null) {
             try {
                 brooklyn().getCatalogClassLoader().loadClass(type);
             } catch (ClassNotFoundException e) {
                 log.debug("Class not found for type '" + type + "'; reporting 404", e);
                 throw WebResourceUtils.notFound("Undefined type '%s'", type);
             }
-            log.info("Entity type '{}' not defined in catalog but is on classpath; continuing", type);
+            log.info(JavaClassNames.simpleClassName(subType)+" type '{}' not defined in catalog but is on classpath; continuing", type);
         }
     }
+    
+    private void checkEntityTypeIsValid(String type) {
+        checkSpecTypeIsValid(type, Entity.class);
+    }
 
     @SuppressWarnings("deprecation")
     private void checkLocationsAreValid(ApplicationSpec applicationSpec) {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
index 38b7815..848701f 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/CatalogResource.java
@@ -34,7 +34,6 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response.Status;
 
 import org.apache.brooklyn.api.catalog.CatalogItem;
-import org.apache.brooklyn.api.catalog.CatalogItem.CatalogItemType;
 import org.apache.brooklyn.api.entity.Application;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.entity.EntitySpec;
@@ -42,6 +41,7 @@ import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.api.policy.Policy;
 import org.apache.brooklyn.api.policy.PolicySpec;
+import org.apache.brooklyn.api.typereg.RegisteredType;
 import org.apache.brooklyn.core.catalog.CatalogPredicates;
 import org.apache.brooklyn.core.catalog.internal.BasicBrooklynCatalog;
 import org.apache.brooklyn.core.catalog.internal.CatalogDto;
@@ -49,6 +49,8 @@ import org.apache.brooklyn.core.catalog.internal.CatalogItemComparator;
 import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements.StringAndArgument;
+import org.apache.brooklyn.core.typereg.RegisteredTypeConstraints;
+import org.apache.brooklyn.core.typereg.RegisteredTypePredicates;
 import org.apache.brooklyn.rest.api.CatalogApi;
 import org.apache.brooklyn.rest.domain.ApiError;
 import org.apache.brooklyn.rest.domain.CatalogEntitySummary;
@@ -146,11 +148,9 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
                 Entitlements.getEntitlementContext().user());
         }
         try {
-            CatalogItem<?, ?> item = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), entityId);
+            RegisteredType item = mgmt().getTypeRegistry().get(entityId, RegisteredTypeConstraints.spec(Entity.class));
             if (item==null) {
                 throw WebResourceUtils.notFound("Entity with id '%s' not found", entityId);
-            } else if (item.getCatalogItemType() != CatalogItemType.ENTITY && item.getCatalogItemType() != CatalogItemType.TEMPLATE) {
-                throw WebResourceUtils.preconditionFailed("Item with id '%s' not an entity", entityId);
             }
             brooklyn().getCatalog().deleteCatalogItem(item.getSymbolicName(), item.getVersion());
         } catch (NoSuchElementException e) {
@@ -170,10 +170,10 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
                 Entitlements.getEntitlementContext().user());
         }
         
-        CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem(symbolicName, version);
+        RegisteredType item = mgmt().getTypeRegistry().get(symbolicName, version);
         if (item == null) {
             throw WebResourceUtils.notFound("Entity with id '%s:%s' not found", symbolicName, version);
-        } else if (item.getCatalogItemType() != CatalogItemType.ENTITY && item.getCatalogItemType() != CatalogItemType.TEMPLATE) {
+        } else if (!RegisteredTypePredicates.IS_ENTITY.apply(item) && !RegisteredTypePredicates.IS_APPLICATION.apply(item)) {
             throw WebResourceUtils.preconditionFailed("Item with id '%s:%s' not an entity", symbolicName, version);
         } else {
             brooklyn().getCatalog().deleteCatalogItem(item.getSymbolicName(), item.getVersion());
@@ -187,10 +187,10 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
                 Entitlements.getEntitlementContext().user());
         }
         
-        CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem(policyId, version);
+        RegisteredType item = mgmt().getTypeRegistry().get(policyId, version);
         if (item == null) {
             throw WebResourceUtils.notFound("Policy with id '%s:%s' not found", policyId, version);
-        } else if (item.getCatalogItemType() != CatalogItemType.POLICY) {
+        } else if (!RegisteredTypePredicates.IS_POLICY.apply(item)) {
             throw WebResourceUtils.preconditionFailed("Item with id '%s:%s' not a policy", policyId, version);
         } else {
             brooklyn().getCatalog().deleteCatalogItem(item.getSymbolicName(), item.getVersion());
@@ -204,10 +204,10 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
                 Entitlements.getEntitlementContext().user());
         }
         
-        CatalogItem<?, ?> item = mgmt().getCatalog().getCatalogItem(locationId, version);
+        RegisteredType item = mgmt().getTypeRegistry().get(locationId, version);
         if (item == null) {
             throw WebResourceUtils.notFound("Location with id '%s:%s' not found", locationId, version);
-        } else if (item.getCatalogItemType() != CatalogItemType.LOCATION) {
+        } else if (!RegisteredTypePredicates.IS_LOCATION.apply(item)) {
             throw WebResourceUtils.preconditionFailed("Item with id '%s:%s' not a location", locationId, version);
         } else {
             brooklyn().getCatalog().deleteCatalogItem(item.getSymbolicName(), item.getVersion());
@@ -404,8 +404,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
                 Entitlements.getEntitlementContext().user());
         }
 
-        CatalogItem<?,?> result = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), itemId);
-        return getCatalogItemIcon(result);
+        return getCatalogItemIcon( mgmt().getTypeRegistry().get(itemId) );
     }
 
     @Override
@@ -415,8 +414,7 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
                 Entitlements.getEntitlementContext().user());
         }
         
-        CatalogItem<?,?> result = brooklyn().getCatalog().getCatalogItem(itemId, version);
-        return getCatalogItemIcon(result);
+        return getCatalogItemIcon(mgmt().getTypeRegistry().get(itemId, version));
     }
 
     @Override
@@ -426,33 +424,27 @@ public class CatalogResource extends AbstractBrooklynRestResource implements Cat
         setDeprecated(itemId, deprecated);
     }
     
+    @SuppressWarnings("deprecation")
     @Override
     public void setDeprecated(String itemId, boolean deprecated) {
         if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_CATALOG_ITEM, StringAndArgument.of(itemId, "deprecated"))) {
             throw WebResourceUtils.unauthorized("User '%s' is not authorized to modify catalog",
                     Entitlements.getEntitlementContext().user());
         }
-        CatalogItem<?, ?> item = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), itemId);
-        if (item==null)
-            throw WebResourceUtils.notFound("Catalog item with id '%s' not found", itemId);
-        item.setDeprecated(deprecated);
-        mgmt().getCatalog().persist(item);
+        CatalogUtils.setDeprecated(mgmt(), itemId, deprecated);
     }
 
+    @SuppressWarnings("deprecation")
     @Override
     public void setDisabled(String itemId, boolean disabled) {
         if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_CATALOG_ITEM, StringAndArgument.of(itemId, "disabled"))) {
             throw WebResourceUtils.unauthorized("User '%s' is not authorized to modify catalog",
                     Entitlements.getEntitlementContext().user());
         }
-        CatalogItem<?, ?> item = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), itemId);
-        if (item==null)
-            throw WebResourceUtils.notFound("Catalog item with id '%s' not found", itemId);
-        item.setDisabled(disabled);
-        mgmt().getCatalog().persist(item);
+        CatalogUtils.setDisabled(mgmt(), itemId, disabled);
     }
 
-    private Response getCatalogItemIcon(CatalogItem<?, ?> result) {
+    private Response getCatalogItemIcon(RegisteredType result) {
         String url = result.getIconUrl();
         if (url==null) {
             log.debug("No icon available for "+result+"; returning "+Status.NO_CONTENT);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EffectorResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EffectorResource.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EffectorResource.java
index fd8dc47..4110d47 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EffectorResource.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EffectorResource.java
@@ -26,15 +26,8 @@ import java.util.concurrent.TimeoutException;
 import javax.annotation.Nullable;
 import javax.ws.rs.core.Response;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.collect.FluentIterable;
-
 import org.apache.brooklyn.api.effector.Effector;
-import org.apache.brooklyn.api.entity.EntityLocal;
+import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.mgmt.Task;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements.StringAndArgument;
@@ -49,6 +42,12 @@ import org.apache.brooklyn.rest.util.WebResourceUtils;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.apache.brooklyn.util.time.Time;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
 
 @HaHotStateRequired
 public class EffectorResource extends AbstractBrooklynRestResource implements EffectorApi {
@@ -57,7 +56,7 @@ public class EffectorResource extends AbstractBrooklynRestResource implements Ef
 
     @Override
     public List<EffectorSummary> list(final String application, final String entityToken) {
-        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        final Entity entity = brooklyn().getEntity(application, entityToken);
         return FluentIterable
                 .from(entity.getEntityType().getEffectors())
                 .filter(new Predicate<Effector<?>>() {
@@ -79,7 +78,7 @@ public class EffectorResource extends AbstractBrooklynRestResource implements Ef
     @Override
     public Response invoke(String application, String entityToken, String effectorName,
             String timeout, Map<String, Object> parameters) {
-        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        final Entity entity = brooklyn().getEntity(application, entityToken);
 
         // TODO check effectors?
         Maybe<Effector<?>> effector = EffectorUtils.findEffectorDeclared(entity, effectorName);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EntityConfigResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EntityConfigResource.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EntityConfigResource.java
index e0e9430..e483d0b 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EntityConfigResource.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EntityConfigResource.java
@@ -23,10 +23,7 @@ import static com.google.common.collect.Iterables.transform;
 import java.util.List;
 import java.util.Map;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.config.BasicConfigKey;
 import org.apache.brooklyn.core.entity.Entities;
@@ -41,6 +38,8 @@ import org.apache.brooklyn.util.core.flags.TypeCoercions;
 import org.apache.brooklyn.util.core.task.ValueResolver;
 import org.apache.brooklyn.util.text.Strings;
 import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Function;
 import com.google.common.base.Predicates;
@@ -54,7 +53,7 @@ public class EntityConfigResource extends AbstractBrooklynRestResource implement
 
     @Override
     public List<EntityConfigSummary> list(final String application, final String entityToken) {
-        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        final Entity entity = brooklyn().getEntity(application, entityToken);
         // TODO merge with keys which have values
         return Lists.newArrayList(transform(
                 entity.getEntityType().getConfigKeys(),
@@ -71,7 +70,7 @@ public class EntityConfigResource extends AbstractBrooklynRestResource implement
     @Override
     public Map<String, Object> batchConfigRead(String application, String entityToken, Boolean raw) {
         // TODO: add test
-        EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        Entity entity = brooklyn().getEntity(application, entityToken);
         Map<ConfigKey<?>, ?> source = ((EntityInternal) entity).config().getBag().getAllConfigAsConfigKeyMap();
         Map<String, Object> result = Maps.newLinkedHashMap();
         for (Map.Entry<ConfigKey<?>, ?> ek : source.entrySet()) {
@@ -93,13 +92,13 @@ public class EntityConfigResource extends AbstractBrooklynRestResource implement
     }
 
     public Object get(boolean preferJson, String application, String entityToken, String configKeyName, Boolean raw) {
-        EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        Entity entity = brooklyn().getEntity(application, entityToken);
         ConfigKey<?> ck = findConfig(entity, configKeyName);
         Object value = ((EntityInternal)entity).config().getRaw(ck).orNull();
         return resolving(value).preferJson(preferJson).asJerseyOutermostReturnValue(true).raw(raw).context(entity).timeout(ValueResolver.PRETTY_QUICK_WAIT).renderAs(ck).resolve();
     }
 
-    private ConfigKey<?> findConfig(EntityLocal entity, String configKeyName) {
+    private ConfigKey<?> findConfig(Entity entity, String configKeyName) {
         ConfigKey<?> ck = entity.getEntityType().getConfigKey(configKeyName);
         if (ck == null)
             ck = new BasicConfigKey<Object>(Object.class, configKeyName);
@@ -109,7 +108,7 @@ public class EntityConfigResource extends AbstractBrooklynRestResource implement
     @SuppressWarnings({ "rawtypes", "unchecked" })
     @Override
     public void setFromMap(String application, String entityToken, Boolean recurse, Map newValues) {
-        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        final Entity entity = brooklyn().getEntity(application, entityToken);
         if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_ENTITY, entity)) {
             throw WebResourceUtils.unauthorized("User '%s' is not authorized to modify entity '%s'",
                     Entitlements.getEntitlementContext().user(), entity);
@@ -134,7 +133,7 @@ public class EntityConfigResource extends AbstractBrooklynRestResource implement
     @SuppressWarnings({ "rawtypes", "unchecked" })
     @Override
     public void set(String application, String entityToken, String configName, Boolean recurse, Object newValue) {
-        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        final Entity entity = brooklyn().getEntity(application, entityToken);
         if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_ENTITY, entity)) {
             throw WebResourceUtils.unauthorized("User '%s' is not authorized to modify entity '%s'",
                     Entitlements.getEntitlementContext().user(), entity);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EntityResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EntityResource.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EntityResource.java
index d1290d2..9575236 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EntityResource.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/EntityResource.java
@@ -35,16 +35,13 @@ import javax.ws.rs.core.Response.ResponseBuilder;
 import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.core.UriInfo;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.mgmt.Task;
 import org.apache.brooklyn.core.mgmt.BrooklynTags;
+import org.apache.brooklyn.core.mgmt.BrooklynTags.NamedStringTag;
 import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
 import org.apache.brooklyn.core.mgmt.EntityManagementUtils;
-import org.apache.brooklyn.core.mgmt.BrooklynTags.NamedStringTag;
 import org.apache.brooklyn.core.mgmt.EntityManagementUtils.CreationResult;
 import org.apache.brooklyn.core.mgmt.entitlement.EntitlementPredicates;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
@@ -61,6 +58,8 @@ import org.apache.brooklyn.rest.util.WebResourceUtils;
 import org.apache.brooklyn.util.collections.MutableList;
 import org.apache.brooklyn.util.core.ResourceUtils;
 import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Collections2;
 import com.google.common.collect.FluentIterable;
@@ -112,7 +111,7 @@ public class EntityResource extends AbstractBrooklynRestResource implements Enti
 
     @Override
     public Response addChildren(String applicationToken, String entityToken, Boolean start, String timeoutS, String yaml) {
-        final EntityLocal parent = brooklyn().getEntity(applicationToken, entityToken);
+        final Entity parent = brooklyn().getEntity(applicationToken, entityToken);
         if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_ENTITY, parent)) {
             throw WebResourceUtils.unauthorized("User '%s' is not authorized to modify entity '%s'",
                     Entitlements.getEntitlementContext().user(), entityToken);
@@ -159,7 +158,7 @@ public class EntityResource extends AbstractBrooklynRestResource implements Enti
 
     @Override
     public Response getIcon(String applicationId, String entityId) {
-        EntityLocal entity = brooklyn().getEntity(applicationId, entityId);
+        Entity entity = brooklyn().getEntity(applicationId, entityId);
         String url = entity.getIconUrl();
         if (url == null)
             return Response.status(Status.NO_CONTENT).build();
@@ -186,7 +185,7 @@ public class EntityResource extends AbstractBrooklynRestResource implements Enti
 
     @Override
     public Response expunge(String application, String entity, boolean release) {
-        EntityLocal entityLocal = brooklyn().getEntity(application, entity);
+        Entity entityLocal = brooklyn().getEntity(application, entity);
         Task<?> task = brooklyn().expunge(entityLocal, release);
         TaskSummary summary = TaskTransformer.FROM_TASK.apply(task);
         return status(ACCEPTED).entity(summary).build();
@@ -206,7 +205,7 @@ public class EntityResource extends AbstractBrooklynRestResource implements Enti
     @Override
     public List<LocationSummary> getLocations(String application, String entity) {
         List<LocationSummary> result = Lists.newArrayList();
-        EntityLocal e = brooklyn().getEntity(application, entity);
+        Entity e = brooklyn().getEntity(application, entity);
         for (Location l : e.getLocations()) {
             result.add(LocationTransformer.newInstance(mgmt(), l, LocationDetailLevel.NONE));
         }
@@ -215,7 +214,7 @@ public class EntityResource extends AbstractBrooklynRestResource implements Enti
 
     @Override
     public String getSpec(String applicationToken, String entityToken) {
-        EntityLocal entity = brooklyn().getEntity(applicationToken, entityToken);
+        Entity entity = brooklyn().getEntity(applicationToken, entityToken);
         NamedStringTag spec = BrooklynTags.findFirst(BrooklynTags.YAML_SPEC_KIND, entity.tags().getTags());
         if (spec == null)
             return null;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/LocationResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/LocationResource.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/LocationResource.java
index c6bf9e7..9f865b3 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/LocationResource.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/LocationResource.java
@@ -32,8 +32,10 @@ import org.slf4j.LoggerFactory;
 import org.apache.brooklyn.api.catalog.CatalogItem;
 import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.location.LocationDefinition;
+import org.apache.brooklyn.api.typereg.RegisteredType;
 import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
 import org.apache.brooklyn.core.location.LocationConfigKeys;
+import org.apache.brooklyn.core.typereg.RegisteredTypePredicates;
 import org.apache.brooklyn.rest.api.LocationApi;
 import org.apache.brooklyn.rest.domain.LocationSpec;
 import org.apache.brooklyn.rest.domain.LocationSummary;
@@ -177,7 +179,7 @@ public class LocationResource extends AbstractBrooklynRestResource implements Lo
     }
     
     private int deleteAllVersions(String locationId) {
-        CatalogItem<?, ?> item = CatalogUtils.getCatalogItemOptionalVersion(mgmt(), locationId);
+        RegisteredType item = mgmt().getTypeRegistry().get(locationId);
         if (item==null) return 0; 
         brooklyn().getCatalog().deleteCatalogItem(item.getSymbolicName(), item.getVersion());
         return 1 + deleteAllVersions(locationId);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
index 469eb0c..fe28576 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/PolicyConfigResource.java
@@ -24,7 +24,6 @@ import java.util.Map;
 import javax.ws.rs.core.Response;
 
 import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.policy.Policy;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
@@ -46,7 +45,7 @@ public class PolicyConfigResource extends AbstractBrooklynRestResource implement
     @Override
     public List<PolicyConfigSummary> list(
             final String application, final String entityToken, final String policyToken) {
-        EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        Entity entity = brooklyn().getEntity(application, entityToken);
         Policy policy = brooklyn().getPolicy(entity, policyToken);
 
         List<PolicyConfigSummary> result = Lists.newArrayList();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/SensorResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/SensorResource.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/SensorResource.java
index 90e434a..303c0df 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/SensorResource.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/SensorResource.java
@@ -24,9 +24,7 @@ import static com.google.common.collect.Iterables.transform;
 import java.util.List;
 import java.util.Map;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.brooklyn.api.entity.EntityLocal;
+import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.api.sensor.Sensor;
 import org.apache.brooklyn.core.entity.EntityInternal;
@@ -40,6 +38,8 @@ import org.apache.brooklyn.rest.util.WebResourceUtils;
 import org.apache.brooklyn.util.core.task.ValueResolver;
 import org.apache.brooklyn.util.text.Strings;
 import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Function;
 import com.google.common.collect.Lists;
@@ -53,7 +53,7 @@ public class SensorResource extends AbstractBrooklynRestResource implements Sens
     @SuppressWarnings("rawtypes")
     @Override
     public List<SensorSummary> list(final String application, final String entityToken) {
-        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        final Entity entity = brooklyn().getEntity(application, entityToken);
 
         return Lists.newArrayList(transform(filter(entity.getEntityType().getSensors(), AttributeSensor.class),
                 new Function<AttributeSensor, SensorSummary>() {
@@ -66,7 +66,7 @@ public class SensorResource extends AbstractBrooklynRestResource implements Sens
 
     @Override
     public Map<String, Object> batchSensorRead(final String application, final String entityToken, final Boolean raw) {
-        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        final Entity entity = brooklyn().getEntity(application, entityToken);
         Map<String, Object> sensorMap = Maps.newHashMap();
         @SuppressWarnings("rawtypes")
         Iterable<AttributeSensor> sensors = filter(entity.getEntityType().getSensors(), AttributeSensor.class);
@@ -80,7 +80,7 @@ public class SensorResource extends AbstractBrooklynRestResource implements Sens
     }
 
     protected Object get(boolean preferJson, String application, String entityToken, String sensorName, Boolean raw) {
-        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        final Entity entity = brooklyn().getEntity(application, entityToken);
         AttributeSensor<?> sensor = findSensor(entity, sensorName);
         Object value = entity.getAttribute(sensor);
         return resolving(value).preferJson(preferJson).asJerseyOutermostReturnValue(true).raw(raw).context(entity).timeout(ValueResolver.PRETTY_QUICK_WAIT).renderAs(sensor).resolve();
@@ -96,7 +96,7 @@ public class SensorResource extends AbstractBrooklynRestResource implements Sens
         return get(true, application, entityToken, sensorName, raw);
     }
 
-    private AttributeSensor<?> findSensor(EntityLocal entity, String name) {
+    private AttributeSensor<?> findSensor(Entity entity, String name) {
         Sensor<?> s = entity.getEntityType().getSensor(name);
         if (s instanceof AttributeSensor) return (AttributeSensor<?>) s;
         return new BasicAttributeSensor<Object>(Object.class, name);
@@ -105,7 +105,7 @@ public class SensorResource extends AbstractBrooklynRestResource implements Sens
     @SuppressWarnings({ "rawtypes", "unchecked" })
     @Override
     public void setFromMap(String application, String entityToken, Map newValues) {
-        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        final Entity entity = brooklyn().getEntity(application, entityToken);
         if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_ENTITY, entity)) {
             throw WebResourceUtils.unauthorized("User '%s' is not authorized to modify entity '%s'",
                 Entitlements.getEntitlementContext().user(), entity);
@@ -125,7 +125,7 @@ public class SensorResource extends AbstractBrooklynRestResource implements Sens
     @SuppressWarnings({ "rawtypes", "unchecked" })
     @Override
     public void set(String application, String entityToken, String sensorName, Object newValue) {
-        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        final Entity entity = brooklyn().getEntity(application, entityToken);
         if (!Entitlements.isEntitled(mgmt().getEntitlementManager(), Entitlements.MODIFY_ENTITY, entity)) {
             throw WebResourceUtils.unauthorized("User '%s' is not authorized to modify entity '%s'",
                 Entitlements.getEntitlementContext().user(), entity);
@@ -139,11 +139,11 @@ public class SensorResource extends AbstractBrooklynRestResource implements Sens
     
     @Override
     public void delete(String application, String entityToken, String sensorName) {
-        final EntityLocal entity = brooklyn().getEntity(application, entityToken);
+        final Entity entity = brooklyn().getEntity(application, entityToken);
         AttributeSensor<?> sensor = findSensor(entity, sensorName);
         if (log.isDebugEnabled())
             log.debug("REST user "+Entitlements.getEntitlementContext()+" deleting sensor "+sensorName);
-        ((EntityInternal)entity).removeAttribute(sensor);
+        ((EntityInternal)entity).sensors().remove(sensor);
     }
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java
index d0a90ea..a9fa4dc 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/resources/ServerResource.java
@@ -34,14 +34,7 @@ import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.FluentIterable;
-
 import org.apache.brooklyn.api.entity.Application;
-import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.api.mgmt.Task;
 import org.apache.brooklyn.api.mgmt.entitlement.EntitlementContext;
@@ -82,6 +75,11 @@ import org.apache.brooklyn.util.text.Strings;
 import org.apache.brooklyn.util.time.CountdownTimer;
 import org.apache.brooklyn.util.time.Duration;
 import org.apache.brooklyn.util.time.Time;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.FluentIterable;
 
 public class ServerResource extends AbstractBrooklynRestResource implements ServerApi {
 
@@ -156,7 +154,7 @@ public class ServerResource extends AbstractBrooklynRestResource implements Serv
                                     // Don't try to stop an already stopping app. Subsequent stops will complete faster
                                     // cancelling the first stop task.
                                     appState != Lifecycle.STOPPING) {
-                                stoppers.add(Entities.invokeEffector((EntityLocal)app, app, StartableApplication.STOP));
+                                stoppers.add(Entities.invokeEffector(app, app, StartableApplication.STOP));
                             } else {
                                 log.debug("App " + app + " is already stopping, will not stop second time. Will wait for original stop to complete.");
                             }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
index e3e53f9..4e9895f 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/CatalogTransformer.java
@@ -64,6 +64,7 @@ public class CatalogTransformer {
         Set<EffectorSummary> effectors = Sets.newTreeSet(SummaryComparators.nameComparator());
 
         try {
+            @SuppressWarnings({ "unchecked", "rawtypes" })
             EntitySpec<?> spec = (EntitySpec<?>) b.getCatalog().createSpec((CatalogItem) item);
             EntityDynamicType typeMap = BrooklynTypes.getDefinedEntityType(spec.getType());
             EntityType type = typeMap.getSnapshot();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EffectorTransformer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EffectorTransformer.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EffectorTransformer.java
index a0c4627..a434659 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EffectorTransformer.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EffectorTransformer.java
@@ -26,7 +26,6 @@ import javax.annotation.Nullable;
 import org.apache.brooklyn.api.effector.Effector;
 import org.apache.brooklyn.api.effector.ParameterType;
 import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.rest.domain.EffectorSummary;
 import org.apache.brooklyn.rest.domain.EffectorSummary.ParameterSummary;
 import org.apache.brooklyn.rest.util.WebResourceUtils;
@@ -42,7 +41,7 @@ import com.google.common.collect.Iterables;
 
 public class EffectorTransformer {
 
-    public static EffectorSummary effectorSummary(final EntityLocal entity, Effector<?> effector) {
+    public static EffectorSummary effectorSummary(final Entity entity, Effector<?> effector) {
         String applicationUri = "/v1/applications/" + entity.getApplicationId();
         String entityUri = applicationUri + "/entities/" + entity.getId();
         return new EffectorSummary(effector.getName(), effector.getReturnTypeName(),



Mime
View raw message