http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/81815f94/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
 
b/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
index a80d12a..6d32aa8 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalEntityFactory.java
@@ -243,17 +243,19 @@ public class InternalEntityFactory extends 
InternalFactory {
     @SuppressWarnings({ "unchecked", "rawtypes" })
     protected <T extends Entity> T loadUnitializedEntity(final T entity, final 
EntitySpec<T> spec) {
         try {
+            final AbstractEntity theEntity = (AbstractEntity) entity;
             if (spec.getDisplayName()!=null)
-                ((AbstractEntity)entity).setDisplayName(spec.getDisplayName());
+                theEntity.setDisplayName(spec.getDisplayName());
             
-            if (spec.getOuterCatalogItemId()!=null) {
-                
((AbstractEntity)entity).setCatalogItemIdHierarchy(spec.getCatalogItemIdHierarchy());
+            if (spec.getCatalogItemId()!=null) {
+                theEntity.setCatalogItemId(spec.getCatalogItemId());
+                
theEntity.setCatalogItemIdSearchPath(spec.getCatalogItemIdSearchPath());
             }
             
             entity.tags().addTags(spec.getTags());
-            addSpecParameters(spec, 
((AbstractEntity)entity).getMutableEntityType());
+            addSpecParameters(spec, theEntity.getMutableEntityType());
             
-            
((AbstractEntity)entity).configure(MutableMap.copyOf(spec.getFlags()));
+            theEntity.configure(MutableMap.copyOf(spec.getFlags()));
             for (Map.Entry<ConfigKey<?>, Object> entry : 
spec.getConfig().entrySet()) {
                 entity.config().set((ConfigKey)entry.getKey(), 
entry.getValue());
             }
@@ -280,7 +282,7 @@ public class InternalEntityFactory extends InternalFactory {
         // except what is being added programmatically.
         // (this logic could get confused if catalog item ID referred to some 
runtime-inherited context,
         // but those semantics should no longer be used -- 
https://issues.apache.org/jira/browse/BROOKLYN-445)
-        if (Strings.isNonBlank(spec.getOuterCatalogItemId())) {
+        if (Strings.isNonBlank(spec.getCatalogItemId())) {
             edType.clearConfigKeys();
         }
         for (SpecParameter<?> param : spec.getParameters()) {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/81815f94/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalLocationFactory.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalLocationFactory.java
 
b/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalLocationFactory.java
index de6a0bd..ad0d0db 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalLocationFactory.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalLocationFactory.java
@@ -114,27 +114,29 @@ public class InternalLocationFactory extends 
InternalFactory {
             
             managementContext.prePreManage(loc);
 
+            final AbstractLocation location = (AbstractLocation) loc;
             if (spec.getDisplayName()!=null)
-                ((AbstractLocation)loc).setDisplayName(spec.getDisplayName());
+                location.setDisplayName(spec.getDisplayName());
             
-            if (spec.getOuterCatalogItemId()!=null) {
-                
((AbstractLocation)loc).setCatalogItemIdHierarchy(spec.getCatalogItemIdHierarchy());
+            if (spec.getCatalogItemId()!=null) {
+                location.setCatalogItemId(spec.getCatalogItemId());
+                
location.setCatalogItemIdSearchPath(spec.getCatalogItemIdSearchPath());
             }
             
             loc.tags().addTags(spec.getTags());
             
             if (isNewStyle(clazz)) {
-                
((AbstractLocation)loc).setManagementContext(managementContext);
-                
((AbstractLocation)loc).configure(ConfigBag.newInstance().putAll(spec.getFlags()).putAll(spec.getConfig()).getAllConfig());
+                location.setManagementContext(managementContext);
+                
location.configure(ConfigBag.newInstance().putAll(spec.getFlags()).putAll(spec.getConfig()).getAllConfig());
             }
             
             for (Map.Entry<ConfigKey<?>, Object> entry : 
spec.getConfig().entrySet()) {
-                
((AbstractLocation)loc).config().set((ConfigKey)entry.getKey(), 
entry.getValue());
+                location.config().set((ConfigKey)entry.getKey(), 
entry.getValue());
             }
             for (Entry<Class<?>, Object> entry : 
spec.getExtensions().entrySet()) {
                 ((LocationInternal)loc).addExtension((Class)entry.getKey(), 
entry.getValue());
             }
-            ((AbstractLocation)loc).init();
+            location.init();
             
             Location parent = spec.getParent();
             if (parent != null) {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/81815f94/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalPolicyFactory.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalPolicyFactory.java
 
b/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalPolicyFactory.java
index 776cfef..4de113c 100644
--- 
a/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalPolicyFactory.java
+++ 
b/core/src/main/java/org/apache/brooklyn/core/objs/proxy/InternalPolicyFactory.java
@@ -103,19 +103,21 @@ public class InternalPolicyFactory extends 
InternalFactory {
 
             T pol = construct(clazz, spec, null);
 
+            final AbstractPolicy policy = (AbstractPolicy) pol;
             if (spec.getDisplayName()!=null) {
-                ((AbstractPolicy)pol).setDisplayName(spec.getDisplayName());
+                policy.setDisplayName(spec.getDisplayName());
             }
-            if (spec.getOuterCatalogItemId()!=null) {
-                
((AbstractPolicy)pol).setCatalogItemIdHierarchy(spec.getCatalogItemIdHierarchy());
+            if (spec.getCatalogItemId()!=null) {
+                policy.setCatalogItemId(spec.getCatalogItemId());
+                
policy.setCatalogItemIdSearchPath(spec.getCatalogItemIdSearchPath());
             }
             
             pol.tags().addTags(spec.getTags());
             
             if (isNewStyle(clazz)) {
-                ((AbstractPolicy)pol).setManagementContext(managementContext);
+                policy.setManagementContext(managementContext);
                 Map<String, Object> config = 
ConfigBag.newInstance().putAll(spec.getFlags()).putAll(spec.getConfig()).getAllConfig();
-                ((AbstractPolicy)pol).configure(MutableMap.copyOf(config)); // 
TODO AbstractPolicy.configure modifies the map
+                policy.configure(MutableMap.copyOf(config)); // TODO 
AbstractPolicy.configure modifies the map
             }
             
             // TODO Can we avoid this for "new-style policies"? Should we just 
trust the configure() method, 
@@ -124,7 +126,7 @@ public class InternalPolicyFactory extends InternalFactory {
             for (Map.Entry<ConfigKey<?>, Object> entry : 
spec.getConfig().entrySet()) {
                 pol.config().set((ConfigKey)entry.getKey(), entry.getValue());
             }
-            ((AbstractPolicy)pol).init();
+            policy.init();
             
             return pol;
             
@@ -143,20 +145,22 @@ public class InternalPolicyFactory extends 
InternalFactory {
             Class<? extends T> clazz = spec.getType();
             
             T enricher = construct(clazz, spec, null);
-            
+
+            final AbstractEnricher theEnricher = (AbstractEnricher) enricher;
             if (spec.getDisplayName()!=null)
-                
((AbstractEnricher)enricher).setDisplayName(spec.getDisplayName());
+                theEnricher.setDisplayName(spec.getDisplayName());
             
-            if (spec.getOuterCatalogItemId()!=null) {
-                
((AbstractEnricher)enricher).setCatalogItemIdHierarchy(spec.getCatalogItemIdHierarchy());
+            if (spec.getCatalogItemId()!=null) {
+                theEnricher.setCatalogItemId(spec.getCatalogItemId());
+                
theEnricher.setCatalogItemIdSearchPath(spec.getCatalogItemIdSearchPath());
             }
             
             enricher.tags().addTags(spec.getTags());
             
             if (isNewStyle(clazz)) {
-                
((AbstractEnricher)enricher).setManagementContext(managementContext);
+                theEnricher.setManagementContext(managementContext);
                 Map<String, Object> config = 
ConfigBag.newInstance().putAll(spec.getFlags()).putAll(spec.getConfig()).getAllConfig();
-                
((AbstractEnricher)enricher).configure(MutableMap.copyOf(config)); // TODO 
AbstractEnricher.configure modifies the map
+                theEnricher.configure(MutableMap.copyOf(config)); // TODO 
AbstractEnricher.configure modifies the map
             }
             
             // TODO Can we avoid this for "new-style policies"? Should we just 
trust the configure() method, 
@@ -165,7 +169,7 @@ public class InternalPolicyFactory extends InternalFactory {
             for (Map.Entry<ConfigKey<?>, Object> entry : 
spec.getConfig().entrySet()) {
                 enricher.config().set((ConfigKey)entry.getKey(), 
entry.getValue());
             }
-            ((AbstractEnricher)enricher).init();
+            theEnricher.init();
             
             return enricher;
             

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/81815f94/core/src/main/java/org/apache/brooklyn/util/core/ClassLoaderUtils.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/brooklyn/util/core/ClassLoaderUtils.java 
b/core/src/main/java/org/apache/brooklyn/util/core/ClassLoaderUtils.java
index 88eb699..b802dfb 100644
--- a/core/src/main/java/org/apache/brooklyn/util/core/ClassLoaderUtils.java
+++ b/core/src/main/java/org/apache/brooklyn/util/core/ClassLoaderUtils.java
@@ -27,7 +27,6 @@ import javax.annotation.Nullable;
 import org.apache.brooklyn.api.catalog.CatalogItem;
 import org.apache.brooklyn.api.entity.Entity;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.api.mgmt.classloading.BrooklynClassLoadingContext;
 import org.apache.brooklyn.core.BrooklynVersion;
 import org.apache.brooklyn.core.catalog.internal.CatalogUtils;
 import org.apache.brooklyn.core.entity.EntityInternal;
@@ -257,7 +256,8 @@ public class ClassLoaderUtils {
                 CatalogItem<?, ?> item = 
CatalogUtils.getCatalogItemOptionalVersion(mgmt, catalogItemId);
                 if (item != null) {
                     BrooklynClassLoadingContextSequential loader = new 
BrooklynClassLoadingContextSequential(mgmt);
-                    loader.add(newClassLoadingContextForCatalogItems(mgmt, 
item.getCatalogItemHierarchy()));
+                    loader.add(newClassLoadingContextForCatalogItems(mgmt, 
item.getCatalogItemId(),
+                        item.getCatalogItemIdSearchPath()));
                     cls = dispatcher.tryLoadFrom(loader, className);
                     if (cls.isPresent()) {
                         return cls;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/81815f94/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindConfigInheritanceTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindConfigInheritanceTest.java
 
b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindConfigInheritanceTest.java
index b340d2a..97faeec 100644
--- 
a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindConfigInheritanceTest.java
+++ 
b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindConfigInheritanceTest.java
@@ -117,9 +117,8 @@ public class RebindConfigInheritanceTest extends 
RebindTestFixtureWithApp {
         checkNewAppNonInheritingKey1(rebindedApp);
         
         String origMementoTidied = 
origMemento.substring(origMemento.indexOf("<entity>"));
-        origMementoTidied = origMementoTidied.replaceFirst("</displayName>", 
"</displayName>\n  <catalogItemHierarchy class=\"ImmutableList\"/>");
         origMementoTidied = Strings.replaceAllNonRegex(origMementoTidied, 
"VERSION", BrooklynVersion.get());
-        Asserts.assertEquals(origMementoTidied, newMemento);
+        Asserts.assertEquals(origMementoTidied, 
newMemento.replaceAll("\n.*searchPath.*\n", "\n"));
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/81815f94/core/src/test/java/org/apache/brooklyn/util/core/ClassLoaderUtilsTest.java
----------------------------------------------------------------------
diff --git 
a/core/src/test/java/org/apache/brooklyn/util/core/ClassLoaderUtilsTest.java 
b/core/src/test/java/org/apache/brooklyn/util/core/ClassLoaderUtilsTest.java
index a9686d5..ce0470d 100644
--- a/core/src/test/java/org/apache/brooklyn/util/core/ClassLoaderUtilsTest.java
+++ b/core/src/test/java/org/apache/brooklyn/util/core/ClassLoaderUtilsTest.java
@@ -325,7 +325,9 @@ public class ClassLoaderUtilsTest {
                 .plan("{\"services\":[{\"type\": \"" + clazz.getName() + 
"\"}]}")
                 .build();
         mgmt.getCatalog().addItem(item);
-        
((EntityInternal)entity).setCatalogItemIdHierarchy(item.getCatalogItemHierarchy());
+        final EntityInternal entityInternal = (EntityInternal) entity;
+        entityInternal.setCatalogItemId(item.getCatalogItemId());
+        
entityInternal.setCatalogItemIdSearchPath(item.getCatalogItemIdSearchPath());
         return entity;
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/81815f94/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/LocationTransformer.java
----------------------------------------------------------------------
diff --git 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/LocationTransformer.java
 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/LocationTransformer.java
index 2ad3608..c612c6f 100644
--- 
a/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/LocationTransformer.java
+++ 
b/rest/rest-resources/src/main/java/org/apache/brooklyn/rest/transform/LocationTransformer.java
@@ -83,7 +83,7 @@ public class LocationTransformer {
             }
         }
 
-        String id = Strings.isNonBlank(optionalExplicitId) ? 
optionalExplicitId : spec!=null && 
Strings.isNonBlank(spec.getOuterCatalogItemId()) ? spec.getOuterCatalogItemId() 
: null;
+        String id = Strings.isNonBlank(optionalExplicitId) ? 
optionalExplicitId : spec!=null && Strings.isNonBlank(spec.getCatalogItemId()) 
? spec.getCatalogItemId() : null;
         URI selfUri = serviceUriBuilder(ub, LocationApi.class, 
"get").build(id);
         
         CatalogLocationSummary catalogSummary = null;
@@ -100,7 +100,7 @@ public class LocationTransformer {
         return new LocationSummary(
                 id,
                 Strings.isNonBlank(name) ? name : spec!=null ? 
spec.getDisplayName() : null,
-                Strings.isNonBlank(specString) ? specString : spec!=null ? 
spec.getOuterCatalogItemId() : null,
+                Strings.isNonBlank(specString) ? specString : spec!=null ? 
spec.getCatalogItemId() : null,
                 null,
                 copyConfig(config, level),
                 catalogSummary,

Reply via email to