brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m4rkmcke...@apache.org
Subject [06/12] brooklyn-server git commit: Delete deprecated LocationSpec.id()
Date Fri, 19 May 2017 17:04:25 GMT
Delete deprecated LocationSpec.id()


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/55eb11fa
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/55eb11fa
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/55eb11fa

Branch: refs/heads/master
Commit: 55eb11fa91e9091447d56bb45116ccc3dc6009df
Parents: f665e57
Author: Aled Sage <aled.sage@gmail.com>
Authored: Thu May 18 16:39:35 2017 +0100
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Fri May 19 13:27:03 2017 +0100

----------------------------------------------------------------------
 .../brooklyn/api/location/LocationSpec.java     | 21 -------------
 .../objs/proxy/InternalLocationFactory.java     | 11 -------
 .../core/location/AbstractLocationTest.java     | 33 ++++++++++++++------
 3 files changed, 23 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/55eb11fa/api/src/main/java/org/apache/brooklyn/api/location/LocationSpec.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/brooklyn/api/location/LocationSpec.java b/api/src/main/java/org/apache/brooklyn/api/location/LocationSpec.java
index 6f84403..e72b8a2 100644
--- a/api/src/main/java/org/apache/brooklyn/api/location/LocationSpec.java
+++ b/api/src/main/java/org/apache/brooklyn/api/location/LocationSpec.java
@@ -78,7 +78,6 @@ public class LocationSpec<T extends Location> extends AbstractBrooklynObjectSpec
         return create(exactType).copyFrom(spec);
     }
 
-    private String id;
     private Location parent;
     private final Map<Class<?>, Object> extensions = Maps.newLinkedHashMap();
 
@@ -90,7 +89,6 @@ public class LocationSpec<T extends Location> extends AbstractBrooklynObjectSpec
     protected LocationSpec<T> copyFrom(LocationSpec<T> otherSpec) {
         LocationSpec<T> result = super.copyFrom(otherSpec).extensions(otherSpec.getExtensions());
         if (otherSpec.getParent() != null) result.parent(otherSpec.getParent());
-        if (otherSpec.getId() != null) result.id(otherSpec.getId());
         return result;
     }
     
@@ -100,15 +98,6 @@ public class LocationSpec<T extends Location> extends AbstractBrooklynObjectSpec
         checkIsNewStyleImplementation(type);
     }
 
-    /**
-     * @deprecated since 0.7.0; instead let the management context pick a random+unique id
-     */
-    @Deprecated
-    public LocationSpec<T> id(String val) {
-        id = val;
-        return this;
-    }
-
     public LocationSpec<T> parent(Location val) {
         parent = checkNotNull(val, "parent");
         return this;
@@ -128,16 +117,6 @@ public class LocationSpec<T extends Location> extends AbstractBrooklynObjectSpec
     }
     
     /**
-     * @return The id of the location to be created, or null if brooklyn can auto-generate
an id
-     * 
-     * @deprecated since 0.7.0; instead let the management context pick a random+unique id
-     */
-    @Deprecated
-    public String getId() {
-        return id;
-    }
-    
-    /**
      * @return The location's parent
      */
     public Location getParent() {

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/55eb11fa/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 b15863d..ffe3e21 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
@@ -29,16 +29,12 @@ import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.core.location.AbstractLocation;
 import org.apache.brooklyn.core.location.Locations;
 import org.apache.brooklyn.core.location.internal.LocationInternal;
-import org.apache.brooklyn.core.mgmt.internal.LocalLocationManager;
 import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
 import org.apache.brooklyn.util.core.config.ConfigBag;
-import org.apache.brooklyn.util.core.flags.FlagUtils;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.ImmutableMap;
-
 /**
  * Creates locations of required types.
  * 
@@ -92,9 +88,6 @@ public class InternalLocationFactory extends InternalFactory {
         if (spec.getFlags().containsKey("id")) {
             throw new IllegalArgumentException("Spec's flags must not contain id; use spec.id()
instead for "+spec);
         }
-        if (spec.getId() != null && ((LocalLocationManager)managementContext.getLocationManager()).isKnownLocationId(spec.getId()))
{
-            throw new IllegalArgumentException("Entity with id "+spec.getId()+" already exists;
cannot create new entity with this explicit id from spec "+spec);
-        }
 
         try {
             Class<? extends T> clazz = spec.getType();
@@ -108,10 +101,6 @@ public class InternalLocationFactory extends InternalFactory {
                 return loc;
             }
 
-            if (spec.getId() != null) {
-                FlagUtils.setFieldsFromFlags(ImmutableMap.of("id", spec.getId()), loc);
-            }
-            
             managementContext.prePreManage(loc);
 
             final AbstractLocation location = (AbstractLocation) loc;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/55eb11fa/core/src/test/java/org/apache/brooklyn/core/location/AbstractLocationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/location/AbstractLocationTest.java
b/core/src/test/java/org/apache/brooklyn/core/location/AbstractLocationTest.java
index 93f74c2..960fa27 100644
--- a/core/src/test/java/org/apache/brooklyn/core/location/AbstractLocationTest.java
+++ b/core/src/test/java/org/apache/brooklyn/core/location/AbstractLocationTest.java
@@ -30,7 +30,6 @@ import org.apache.brooklyn.api.location.Location;
 import org.apache.brooklyn.api.location.LocationSpec;
 import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.location.AbstractLocation;
 import org.apache.brooklyn.core.location.internal.LocationInternal;
 import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
 import org.apache.brooklyn.util.collections.MutableMap;
@@ -41,7 +40,6 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
 
 public class AbstractLocationTest {
 
@@ -58,6 +56,18 @@ public class AbstractLocationTest {
         }
     }
 
+    public static class LocationWithOverriddenId extends ConcreteLocation {
+        @SetFromFlag
+        String overriddenId;
+        
+        public LocationWithOverriddenId() {
+        }
+
+        public String getId() {
+            return overriddenId;
+        }
+    }
+
     private ManagementContext mgmt;
 
     @BeforeMethod(alwaysRun=true)
@@ -74,18 +84,21 @@ public class AbstractLocationTest {
         return createConcrete(MutableMap.<String,Object>of());
     }
     private ConcreteLocation createConcrete(Map<String,?> flags) {
-        return createConcrete(null, flags);
-    }
-    @SuppressWarnings("deprecation")
-    private ConcreteLocation createConcrete(String id, Map<String,?> flags) {
-        return mgmt.getLocationManager().createLocation( LocationSpec.create(ConcreteLocation.class).id(id).configure(flags)
);
+        return mgmt.getLocationManager().createLocation( LocationSpec.create(ConcreteLocation.class).configure(flags)
);
     }
     
     @Test
     public void testEqualsUsesId() {
-        Location l1 = createConcrete("1", MutableMap.of("name", "bob"));
-        Location l1b = new ConcreteLocation(ImmutableMap.of("id", 1));
-        Location l2 = createConcrete("2", MutableMap.of("name", "frank"));
+        Location l1 = mgmt.getLocationManager().createLocation(LocationSpec.create(LocationWithOverriddenId.class)
+                .configure("overriddenId", "id1")
+                .configure("myfield", "bob"));
+        Location l1b = mgmt.getLocationManager().createLocation(LocationSpec.create(LocationWithOverriddenId.class)
+                .configure("overriddenId", "id1")
+                .configure("myfield", "frank"));
+        Location l2 = mgmt.getLocationManager().createLocation(LocationSpec.create(LocationWithOverriddenId.class)
+                .configure("overriddenId", "id2")
+                .configure("myfield", "bob"));
+        
         assertEquals(l1, l1b);
         assertNotEquals(l1, l2);
     }


Mime
View raw message