brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grk...@apache.org
Subject [1/2] incubator-brooklyn git commit: Change extension map to a reference
Date Wed, 01 Apr 2015 20:23:04 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master d08289911 -> 9a1c59a07


Change extension map to a reference

Allows persisting of locations with dynamically added extensions


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

Branch: refs/heads/master
Commit: c307b7e9d63df5d9b0c022419eb0099cca4d2368
Parents: d082899
Author: Andrew Kennedy <grkvlt@apache.org>
Authored: Mon Feb 16 23:35:32 2015 +0000
Committer: Andrew Kennedy <grkvlt@apache.org>
Committed: Wed Apr 1 21:21:05 2015 +0100

----------------------------------------------------------------------
 .../java/brooklyn/location/basic/AbstractLocation.java   | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c307b7e9/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/basic/AbstractLocation.java b/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
index a576a60..8696378 100644
--- a/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
+++ b/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
@@ -110,8 +110,8 @@ public abstract class AbstractLocation extends AbstractBrooklynObject
implements
 
     private boolean inConstruction;
 
-    private final Map<Class<?>, Object> extensions = Maps.newConcurrentMap();
-    
+    private Reference<Map<Class<?>, Object>> extensions = new BasicReference<Map<Class<?>,
Object>>(Maps.<Class<?>, Object>newConcurrentMap());
+
     private final LocationDynamicType locationType;
 
     /**
@@ -665,13 +665,13 @@ public abstract class AbstractLocation extends AbstractBrooklynObject
implements
     
     @Override
     public boolean hasExtension(Class<?> extensionType) {
-        return extensions.containsKey(checkNotNull(extensionType, "extensionType"));
+        return extensions.get().containsKey(checkNotNull(extensionType, "extensionType"));
     }
 
     @Override
     @SuppressWarnings("unchecked")
     public <T> T getExtension(Class<T> extensionType) {
-        Object extension = extensions.get(checkNotNull(extensionType, "extensionType"));
+        Object extension = extensions.get().get(checkNotNull(extensionType, "extensionType"));
         if (extension == null) {
             throw new IllegalArgumentException("No extension of type "+extensionType+" registered
for location "+this);
         }
@@ -683,8 +683,9 @@ public abstract class AbstractLocation extends AbstractBrooklynObject
implements
         checkNotNull(extensionType, "extensionType");
         checkNotNull(extension, "extension");
         checkArgument(extensionType.isInstance(extension), "extension %s does not implement
%s", extension, extensionType);
-        extensions.put(extensionType, extension);
+        extensions.get().put(extensionType, extension);
     }
+
     @Override
     public Map<String, String> toMetadataRecord() {
         ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();


Mime
View raw message