You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2015/11/02 17:43:01 UTC

[4/9] incubator-brooklyn git commit: more converting CatalogItem access to RegisteredType

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java
index 7bd36f6..4e6e15b 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/EntityTransformer.java
@@ -28,7 +28,6 @@ import java.util.Map;
 import org.apache.brooklyn.api.catalog.CatalogConfig;
 import org.apache.brooklyn.api.entity.Application;
 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.render.RendererHints;
 import org.apache.brooklyn.rest.domain.EntityConfigSummary;
@@ -104,7 +103,7 @@ public class EntityTransformer {
     /** generates a representation for a given config key, 
      * with label inferred from annoation in the entity class,
      * and links pointing to the entity and the applicaiton */
-    public static EntityConfigSummary entityConfigSummary(EntityLocal entity, ConfigKey<?> config) {
+    public static EntityConfigSummary entityConfigSummary(Entity entity, ConfigKey<?> config) {
       /*
        * following code nearly there to get the @CatalogConfig annotation
        * in the class and use that to populate a label

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/PolicyTransformer.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/PolicyTransformer.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/PolicyTransformer.java
index 39bc783..b29e010 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/PolicyTransformer.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/transform/PolicyTransformer.java
@@ -22,7 +22,6 @@ import java.net.URI;
 import java.util.Map;
 
 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.policy.Policies;
@@ -56,7 +55,7 @@ public class PolicyTransformer {
         return new PolicySummary(policy.getId(), policy.getDisplayName(), policy.getCatalogItemId(), ApplicationTransformer.statusFromLifecycle(Policies.getPolicyStatus(policy)), links);
     }
 
-    public static PolicyConfigSummary policyConfigSummary(BrooklynRestResourceUtils utils, ApplicationSummary application, EntityLocal entity, Policy policy, ConfigKey<?> config) {
+    public static PolicyConfigSummary policyConfigSummary(BrooklynRestResourceUtils utils, ApplicationSummary application, Entity entity, Policy policy, ConfigKey<?> config) {
         PolicyConfigSummary summary = policyConfigSummary(utils, entity, policy, config);
 //        TODO
 //        if (!entity.getApplicationId().equals(application.getInstance().getId()))
@@ -64,7 +63,7 @@ public class PolicyTransformer {
         return summary;
     }
 
-    public static PolicyConfigSummary policyConfigSummary(BrooklynRestResourceUtils utils, EntityLocal entity, Policy policy, ConfigKey<?> config) {
+    public static PolicyConfigSummary policyConfigSummary(BrooklynRestResourceUtils utils, Entity entity, Policy policy, ConfigKey<?> config) {
         String applicationUri = "/v1/applications/" + entity.getApplicationId();
         String entityUri = applicationUri + "/entities/" + entity.getId();
         String policyUri = entityUri + "/policies/" + policy.getId();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
index f30c7ec..2d9054a 100644
--- a/usage/rest-server/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
+++ b/usage/rest-server/src/main/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtils.java
@@ -23,6 +23,7 @@ import static org.apache.brooklyn.rest.util.WebResourceUtils.notFound;
 
 import java.lang.reflect.Constructor;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -36,26 +37,28 @@ import org.apache.brooklyn.api.catalog.BrooklynCatalog;
 import org.apache.brooklyn.api.catalog.CatalogItem;
 import org.apache.brooklyn.api.entity.Application;
 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.location.LocationRegistry;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.api.mgmt.Task;
 import org.apache.brooklyn.api.policy.Policy;
+import org.apache.brooklyn.api.typereg.RegisteredType;
 import org.apache.brooklyn.camp.brooklyn.BrooklynCampConstants;
 import org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent;
 import org.apache.brooklyn.camp.brooklyn.spi.dsl.methods.DslComponent.Scope;
 import org.apache.brooklyn.config.ConfigKey;
+import org.apache.brooklyn.core.catalog.CatalogPredicates;
+import org.apache.brooklyn.core.catalog.internal.CatalogItemComparator;
 import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
 import org.apache.brooklyn.core.entity.Attributes;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.EntityInternal;
-import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
 import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements;
 import org.apache.brooklyn.core.mgmt.entitlement.Entitlements.StringAndArgument;
 import org.apache.brooklyn.core.objs.BrooklynTypes;
+import org.apache.brooklyn.core.typereg.RegisteredTypes;
 import org.apache.brooklyn.enricher.stock.Enrichers;
 import org.apache.brooklyn.entity.stock.BasicApplication;
 import org.apache.brooklyn.rest.domain.ApplicationSpec;
@@ -73,7 +76,9 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSortedSet;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
@@ -137,10 +142,10 @@ public class BrooklynRestResourceUtils {
      * in which case names will be searched recursively (and the application is required). 
      * 
      * @throws 404 or 412 (unless input is null in which case output is null) */
-    public EntityLocal getEntity(String application, String entity) {
+    public Entity getEntity(String application, String entity) {
         if (entity==null) return null;
         Application app = application!=null ? getApplication(application) : null;
-        EntityLocal e = (EntityLocal) mgmt.getEntityManager().getEntity(entity);
+        Entity e = (Entity) mgmt.getEntityManager().getEntity(entity);
         
         if (e!=null) {
             if (!Entitlements.isEntitled(mgmt.getEntitlementManager(), Entitlements.SEE_ENTITY, e)) {
@@ -195,11 +200,11 @@ public class BrooklynRestResourceUtils {
     /** walks the hierarchy (depth-first) at root (often an Application) looking for
      * an entity matching the given ID or name; returns the first such entity, or null if none found
      **/
-    public EntityLocal searchForEntityNamed(Entity root, String entity) {
-        if (root.getId().equals(entity) || entity.equals(root.getDisplayName())) return (EntityLocal) root;
+    public Entity searchForEntityNamed(Entity root, String entity) {
+        if (root.getId().equals(entity) || entity.equals(root.getDisplayName())) return (Entity) root;
         for (Entity child: root.getChildren()) {
             Entity result = searchForEntityNamed(child, entity);
-            if (result!=null) return (EntityLocal) result;
+            if (result!=null) return (Entity) result;
         }
         return null;
     }
@@ -208,14 +213,16 @@ public class BrooklynRestResourceUtils {
         String catalogItemId;
         Class<? extends Entity> clazz;
         
-        @SuppressWarnings("unchecked")
+        @SuppressWarnings({ "unchecked" })
         private FindItemAndClass inferFrom(String type) {
-            BrooklynCatalog catalog = getCatalog();
-            CatalogItem<?, ?> item = CatalogUtils.getCatalogItemOptionalVersion(mgmt, type);
+            RegisteredType item = mgmt.getTypeRegistry().get(type);
             if (item==null) {
-                // although the method was deprecated in 0.7.0, its use here was not warned until 0.9.0;
-                // therefore this behaviour should not be changed until after 0.9.0
-                item = catalog.getCatalogItemForType(type);
+                // deprecated attempt to load an item not in the type registry
+                
+                // although the method called was deprecated in 0.7.0, its use here was not warned until 0.9.0;
+                // therefore this behaviour should not be changed until after 0.9.0;
+                // at which point it should try a pojo load (see below)
+                item = getCatalogItemForType(type);
                 if (item!=null) {
                     log.warn("Creating application for requested type `"+type+" using item "+item+"; "
                         + "the registered type name ("+item.getSymbolicName()+") should be used from the spec instead, "
@@ -226,12 +233,12 @@ public class BrooklynRestResourceUtils {
             
             if (item != null) {
                 return setAs(
-                    catalog.createSpec((CatalogItem<Entity,org.apache.brooklyn.api.entity.EntitySpec<Entity>>)item).getType(),
+                    mgmt.getTypeRegistry().createSpec(item, null, org.apache.brooklyn.api.entity.EntitySpec.class).getType(),
                     item.getId());
             } else {
                 try {
                     setAs(
-                        (Class<? extends Entity>) catalog.getRootClassLoader().loadClass(type),
+                        (Class<? extends Entity>) getCatalog().getRootClassLoader().loadClass(type),
                         null);
                     log.info("Catalog does not contain item for type {}; loaded class directly instead", type);
                     return this;
@@ -247,6 +254,50 @@ public class BrooklynRestResourceUtils {
             this.catalogItemId = catalogItemId;
             return this;
         }
+        
+        @Deprecated // see caller
+        private RegisteredType getCatalogItemForType(String typeName) {
+            final RegisteredType resultI;
+            if (CatalogUtils.looksLikeVersionedId(typeName)) {
+                //All catalog identifiers of the form xxxx:yyyy are composed of symbolicName+version.
+                //No javaType is allowed as part of the identifier.
+                resultI = mgmt.getTypeRegistry().get(typeName);
+            } else {
+                //Usually for catalog items with javaType (that is items from catalog.xml)
+                //the symbolicName and javaType match because symbolicName (was ID)
+                //is not specified explicitly. But could be the case that there is an item
+                //whose symbolicName is explicitly set to be different from the javaType.
+                //Note that in the XML the attribute is called registeredTypeName.
+                Iterable<CatalogItem<Object,Object>> resultL = mgmt.getCatalog().getCatalogItems(CatalogPredicates.javaType(Predicates.equalTo(typeName)));
+                if (!Iterables.isEmpty(resultL)) {
+                    //Push newer versions in front of the list (not that there should
+                    //be more than one considering the items are coming from catalog.xml).
+                    resultI = RegisteredTypes.of(sortVersionsDesc(resultL).iterator().next());
+                    if (log.isDebugEnabled() && Iterables.size(resultL)>1) {
+                        log.debug("Found "+Iterables.size(resultL)+" matches in catalog for type "+typeName+"; returning the result with preferred version, "+resultI);
+                    }
+                } else {
+                    //As a last resort try searching for items with the same symbolicName supposedly
+                    //different from the javaType.
+                    resultI = mgmt.getTypeRegistry().get(typeName, BrooklynCatalog.DEFAULT_VERSION);
+                    if (resultI != null) {
+                        if (resultI.getJavaType() == null) {
+                            //Catalog items scanned from the classpath (using reflection and annotations) now
+                            //get yaml spec rather than a java type. Can't use those when creating apps from
+                            //the legacy app spec format.
+                            log.warn("Unable to find catalog item for type "+typeName +
+                                    ". There is an existing catalog item with ID " + resultI.getId() +
+                                    " but it doesn't define a class type.");
+                            return null;
+                        }
+                    }
+                }
+            }
+            return resultI;
+        }
+        private <T,SpecT> Collection<CatalogItem<T,SpecT>> sortVersionsDesc(Iterable<CatalogItem<T,SpecT>> versions) {
+            return ImmutableSortedSet.orderedBy(CatalogItemComparator.<T,SpecT>getInstance()).addAll(versions).build();
+        }
     }
     
     @SuppressWarnings({ "deprecation" })
@@ -281,11 +332,11 @@ public class BrooklynRestResourceUtils {
         }
 
         try {
-            if (ApplicationBuilder.class.isAssignableFrom(itemAndClass.clazz)) {
+            if (org.apache.brooklyn.core.entity.factory.ApplicationBuilder.class.isAssignableFrom(itemAndClass.clazz)) {
                 // warning only added in 0.9.0
                 log.warn("Using deprecated ApplicationBuilder "+itemAndClass.clazz+"; callers must migrate to use of Application");
                 Constructor<?> constructor = itemAndClass.clazz.getConstructor();
-                ApplicationBuilder appBuilder = (ApplicationBuilder) constructor.newInstance();
+                org.apache.brooklyn.core.entity.factory.ApplicationBuilder appBuilder = (org.apache.brooklyn.core.entity.factory.ApplicationBuilder) constructor.newInstance();
                 if (!Strings.isEmpty(name)) appBuilder.appDisplayName(name);
                 if (entities.size() > 0)
                     log.warn("Cannot supply additional entities when using an ApplicationBuilder; ignoring in spec {}", spec);
@@ -342,7 +393,7 @@ public class BrooklynRestResourceUtils {
     }
 
     public Task<?> start(Application app, List<? extends Location> locations) {
-        return Entities.invokeEffector((EntityLocal)app, app, Startable.START,
+        return Entities.invokeEffector((Entity)app, app, Startable.START,
                 MutableMap.of("locations", locations));
     }
 
@@ -381,7 +432,8 @@ public class BrooklynRestResourceUtils {
         return result;
     }
     
-    protected void configureRenderingMetadata(ApplicationSpec spec, ApplicationBuilder appBuilder) {
+    @SuppressWarnings("deprecation")
+    protected void configureRenderingMetadata(ApplicationSpec spec, org.apache.brooklyn.core.entity.factory.ApplicationBuilder appBuilder) {
         appBuilder.configure(getRenderingConfigurationFor(spec.getType()));
     }
 
@@ -395,7 +447,7 @@ public class BrooklynRestResourceUtils {
 
     protected Map<?, ?> getRenderingConfigurationFor(String catalogId) {
         MutableMap<Object, Object> result = MutableMap.of();
-        CatalogItem<?,?> item = CatalogUtils.getCatalogItemOptionalVersion(mgmt, catalogId);
+        RegisteredType item = mgmt.getTypeRegistry().get(catalogId);
         if (item==null) return result;
         
         result.addIfNotNull("iconUrl", item.getIconUrl());
@@ -527,7 +579,7 @@ public class BrooklynRestResourceUtils {
     
     public Iterable<Entity> descendantsOfAnyType(String application, String entity) {
         List<Entity> result = Lists.newArrayList();
-        EntityLocal e = getEntity(application, entity);
+        Entity e = getEntity(application, entity);
         gatherAllDescendants(e, result);
         return result;
     }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java
index c992ec2..7e9c910 100644
--- a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java
+++ b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/domain/ApplicationTest.java
@@ -27,7 +27,6 @@ import java.io.IOException;
 import java.net.URI;
 import java.util.Map;
 
-import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
@@ -84,7 +83,7 @@ public class ApplicationTest {
         ManagementContext mgmt = LocalManagementContextForTests.newInstance();
         try {
             TestApplication app = mgmt.getEntityManager().createEntity(org.apache.brooklyn.api.entity.EntitySpec.create(TestApplication.class));
-            TestApplication e2 = app.addChild(org.apache.brooklyn.api.entity.EntitySpec.create(TestApplication.class));
+            app.addChild(org.apache.brooklyn.api.entity.EntitySpec.create(TestApplication.class));
             Asserts.assertEqualsIgnoringOrder(mgmt.getApplications(), ImmutableList.of(app));
         } finally {
             Entities.destroyAll(mgmt);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResetTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResetTest.java b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResetTest.java
index 6adfdb5..0b5daf5 100644
--- a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResetTest.java
+++ b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResetTest.java
@@ -27,6 +27,7 @@ import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 import org.apache.brooklyn.api.catalog.BrooklynCatalog;
+import org.apache.brooklyn.api.typereg.BrooklynTypeRegistry;
 import org.apache.brooklyn.core.test.TestHttpRequestHandler;
 import org.apache.brooklyn.core.test.TestHttpServer;
 import org.apache.brooklyn.rest.testing.BrooklynRestResourceTest;
@@ -104,9 +105,9 @@ public class CatalogResetTest extends BrooklynRestResourceTest {
     }
     
     private void assertItems() {
-        BrooklynCatalog catalog = getManagementContext().getCatalog();
-        assertNotNull(catalog.getCatalogItem("org.apache.brooklyn.entity.stock.BasicApplication", BrooklynCatalog.DEFAULT_VERSION));
-        assertNotNull(catalog.getCatalogItem("org.apache.brooklyn.test.osgi.entities.SimpleApplication", BrooklynCatalog.DEFAULT_VERSION));
+        BrooklynTypeRegistry types = getManagementContext().getTypeRegistry();
+        assertNotNull(types.get("org.apache.brooklyn.entity.stock.BasicApplication", BrooklynCatalog.DEFAULT_VERSION));
+        assertNotNull(types.get("org.apache.brooklyn.test.osgi.entities.SimpleApplication", BrooklynCatalog.DEFAULT_VERSION));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
index 3ce0e56..3883ce8 100644
--- a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
+++ b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/resources/CatalogResourceTest.java
@@ -33,8 +33,8 @@ import java.util.Set;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
-import org.apache.brooklyn.api.catalog.CatalogItem;
-import org.apache.brooklyn.api.catalog.CatalogItem.CatalogBundle;
+import org.apache.brooklyn.api.typereg.OsgiBundleWithUrl;
+import org.apache.brooklyn.api.typereg.RegisteredType;
 import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
 import org.apache.brooklyn.core.mgmt.osgi.OsgiStandaloneTest;
 import org.apache.brooklyn.policy.autoscaling.AutoScalerPolicy;
@@ -113,9 +113,9 @@ public class CatalogResourceTest extends BrooklynRestResourceTest {
         assertEquals(entityItem.getVersion(), TEST_VERSION);
 
         // and internally let's check we have libraries
-        CatalogItem<?, ?> item = getManagementContext().getCatalog().getCatalogItem(symbolicName, TEST_VERSION);
+        RegisteredType item = getManagementContext().getTypeRegistry().get(symbolicName, TEST_VERSION);
         Assert.assertNotNull(item);
-        Collection<CatalogBundle> libs = item.getLibraries();
+        Collection<OsgiBundleWithUrl> libs = item.getLibraries();
         assertEquals(libs.size(), 1);
         assertEquals(Iterables.getOnlyElement(libs).getUrl(), bundleUrl);
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/test/java/org/apache/brooklyn/rest/test/entity/brooklynnode/DeployBlueprintTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/test/entity/brooklynnode/DeployBlueprintTest.java b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/test/entity/brooklynnode/DeployBlueprintTest.java
index 980e844..2ab62a9 100644
--- a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/test/entity/brooklynnode/DeployBlueprintTest.java
+++ b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/test/entity/brooklynnode/DeployBlueprintTest.java
@@ -24,7 +24,6 @@ import java.net.URI;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.entity.EntitySpec;
 import org.apache.brooklyn.api.mgmt.EntityManager;
 import org.apache.brooklyn.entity.brooklynnode.BrooklynNode;
@@ -63,7 +62,7 @@ public class DeployBlueprintTest extends BrooklynRestApiLauncherTestFixture {
         EntitySpec<BrooklynNode> spec = EntitySpec.create(BrooklynNode.class);
         EntityManager mgr = getManagementContextFromJettyServerAttributes(server).getEntityManager();
         BrooklynNode node = mgr.createEntity(spec);
-        ((EntityLocal)node).sensors().set(BrooklynNode.WEB_CONSOLE_URI, webConsoleUri);
+        node.sensors().set(BrooklynNode.WEB_CONSOLE_URI, webConsoleUri);
         mgr.manage(node);
         Map<String, String> params = ImmutableMap.of(DeployBlueprintEffector.BLUEPRINT_CAMP_PLAN.getName(), "{ services: [ serviceType: \"java:"+BasicApplication.class.getName()+"\" ] }");
         String id = node.invoke(BrooklynNode.DEPLOY_BLUEPRINT, params).getUnchecked();

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/test/java/org/apache/brooklyn/rest/testing/mocks/CapitalizePolicy.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/testing/mocks/CapitalizePolicy.java b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/testing/mocks/CapitalizePolicy.java
index 412ab7e..7d80a6f 100644
--- a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/testing/mocks/CapitalizePolicy.java
+++ b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/testing/mocks/CapitalizePolicy.java
@@ -21,6 +21,7 @@ package org.apache.brooklyn.rest.testing.mocks;
 import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.core.policy.AbstractPolicy;
 
+@SuppressWarnings("deprecation")
 public class CapitalizePolicy extends AbstractPolicy {
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/usage/rest-server/src/test/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
----------------------------------------------------------------------
diff --git a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
index 0c7e849..48908e3 100644
--- a/usage/rest-server/src/test/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
+++ b/usage/rest-server/src/test/java/org/apache/brooklyn/rest/util/BrooklynRestResourceUtilsTest.java
@@ -27,24 +27,20 @@ import java.util.Map;
 import org.apache.brooklyn.api.catalog.Catalog;
 import org.apache.brooklyn.api.entity.Application;
 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.core.catalog.internal.CatalogItemBuilder;
 import org.apache.brooklyn.core.catalog.internal.CatalogTemplateItemDto;
 import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
 import org.apache.brooklyn.core.entity.AbstractApplication;
-import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
 import org.apache.brooklyn.core.objs.proxy.EntityProxy;
 import org.apache.brooklyn.core.policy.AbstractPolicy;
 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.test.entity.TestEntityImpl;
 import org.apache.brooklyn.entity.stock.BasicEntity;
 import org.apache.brooklyn.rest.domain.ApplicationSpec;
 import org.apache.brooklyn.rest.domain.EntitySpec;
-import org.apache.brooklyn.util.collections.MutableMap;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/50ebfafb/utils/common/src/main/java/org/apache/brooklyn/util/guava/IllegalStateExceptionSupplier.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/guava/IllegalStateExceptionSupplier.java b/utils/common/src/main/java/org/apache/brooklyn/util/guava/IllegalStateExceptionSupplier.java
index deaba53..a79a8c9 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/guava/IllegalStateExceptionSupplier.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/guava/IllegalStateExceptionSupplier.java
@@ -18,26 +18,38 @@
  */
 package org.apache.brooklyn.util.guava;
 
+import org.apache.brooklyn.util.exceptions.Exceptions;
+
 import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
 
 public class IllegalStateExceptionSupplier implements Supplier<RuntimeException> {
 
     public static final IllegalStateExceptionSupplier EMPTY_EXCEPTION = new IllegalStateExceptionSupplier();
     
-    protected final String message;
+    protected final Supplier<String> message;
     protected final Throwable cause;
     
-    public IllegalStateExceptionSupplier() { this(null, null); }
+    public IllegalStateExceptionSupplier() { this((Supplier<String>)null, null); }
     public IllegalStateExceptionSupplier(String message) { this(message, null); }
-    public IllegalStateExceptionSupplier(Throwable cause) { this(cause!=null ? cause.getMessage() : null, cause); }
-    public IllegalStateExceptionSupplier(String message, Throwable cause) { 
+    public IllegalStateExceptionSupplier(Throwable cause) { this(new CollapseTextSupplier(cause), cause); }
+    public IllegalStateExceptionSupplier(String message, Throwable cause) { this(Suppliers.ofInstance(message), cause); } 
+    public IllegalStateExceptionSupplier(Supplier<String> message, Throwable cause) { 
         this.message = message;
         this.cause = cause;
     }
-    
+
+    private static class CollapseTextSupplier implements Supplier<String> {
+        final Throwable cause;
+        CollapseTextSupplier(Throwable cause) { this.cause = cause; }
+        @Override
+        public String get() {
+            return Exceptions.collapseText(cause);
+        }
+    }
     @Override
     public RuntimeException get() {
-        return new IllegalStateException(message, cause);
+        return new IllegalStateException(message==null ? null : message.get(), cause);
     }
 
 }