brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sjcorb...@apache.org
Subject [09/17] incubator-brooklyn git commit: Eliminate duplication between implementations of ConfigurationSupportInternal
Date Wed, 14 Oct 2015 13:55:55 GMT
Eliminate duplication between implementations of ConfigurationSupportInternal


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

Branch: refs/heads/master
Commit: 2f9b9e1f3ca33a5b933b0dac0110a29b7a61ff25
Parents: 5423137
Author: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Authored: Thu Oct 8 12:25:27 2015 +0100
Committer: Sam Corbett <sam.corbett@cloudsoftcorp.com>
Committed: Thu Oct 8 17:54:43 2015 +0100

----------------------------------------------------------------------
 .../brooklyn/core/entity/AbstractEntity.java    | 28 +----------
 .../core/location/AbstractLocation.java         | 29 +----------
 .../AbstractConfigurationSupportInternal.java   | 53 ++++++++++++++++++++
 .../core/objs/AbstractEntityAdjunct.java        | 28 +----------
 .../core/objs/BrooklynObjectInternal.java       |  4 +-
 5 files changed, 60 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f9b9e1f/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
index eb919a7..1291587 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/AbstractEntity.java
@@ -77,6 +77,7 @@ import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
 import org.apache.brooklyn.core.mgmt.internal.SubscriptionTracker;
 import org.apache.brooklyn.core.mgmt.rebind.BasicEntityRebindSupport;
 import org.apache.brooklyn.core.objs.AbstractBrooklynObject;
+import org.apache.brooklyn.core.objs.AbstractConfigurationSupportInternal;
 import org.apache.brooklyn.core.objs.AbstractEntityAdjunct;
 import org.apache.brooklyn.core.objs.AbstractEntityAdjunct.AdjunctTagSupport;
 import org.apache.brooklyn.core.policy.AbstractPolicy;
@@ -1134,7 +1135,7 @@ public abstract class AbstractEntity extends AbstractBrooklynObject
implements E
      */
     @Beta
     // TODO revert to private when config() is reverted to return ConfigurationSupportInternal
-    public class BasicConfigurationSupport implements ConfigurationSupportInternal {
+    public class BasicConfigurationSupport extends AbstractConfigurationSupportInternal {
 
         @Override
         public <T> T get(ConfigKey<T> key) {
@@ -1142,31 +1143,16 @@ public abstract class AbstractEntity extends AbstractBrooklynObject
implements E
         }
 
         @Override
-        public <T> T get(HasConfigKey<T> key) {
-            return get(key.getConfigKey());
-        }
-
-        @Override
         public <T> T set(ConfigKey<T> key, T val) {
             return setConfigInternal(key, val);
         }
 
         @Override
-        public <T> T set(HasConfigKey<T> key, T val) {
-            return set(key.getConfigKey(), val);
-        }
-
-        @Override
         public <T> T set(ConfigKey<T> key, Task<T> val) {
             return setConfigInternal(key, val);
         }
 
         @Override
-        public <T> T set(HasConfigKey<T> key, Task<T> val) {
-            return set(key.getConfigKey(), val);
-        }
-
-        @Override
         public ConfigBag getBag() {
             return configsInternal.getAllConfigBag();
         }
@@ -1182,21 +1168,11 @@ public abstract class AbstractEntity extends AbstractBrooklynObject
implements E
         }
 
         @Override
-        public Maybe<Object> getRaw(HasConfigKey<?> key) {
-            return getRaw(key.getConfigKey());
-        }
-
-        @Override
         public Maybe<Object> getLocalRaw(ConfigKey<?> key) {
             return configsInternal.getConfigRaw(key, false);
         }
 
         @Override
-        public Maybe<Object> getLocalRaw(HasConfigKey<?> key) {
-            return getLocalRaw(key.getConfigKey());
-        }
-
-        @Override
         public void addToLocalBag(Map<String, ?> vals) {
             configsInternal.addToLocalBag(vals);
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f9b9e1f/core/src/main/java/org/apache/brooklyn/core/location/AbstractLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/location/AbstractLocation.java b/core/src/main/java/org/apache/brooklyn/core/location/AbstractLocation.java
index 26e58e1..1f6788c 100644
--- a/core/src/main/java/org/apache/brooklyn/core/location/AbstractLocation.java
+++ b/core/src/main/java/org/apache/brooklyn/core/location/AbstractLocation.java
@@ -59,6 +59,7 @@ import org.apache.brooklyn.core.mgmt.internal.ManagementContextInternal;
 import org.apache.brooklyn.core.mgmt.internal.SubscriptionTracker;
 import org.apache.brooklyn.core.mgmt.rebind.BasicLocationRebindSupport;
 import org.apache.brooklyn.core.objs.AbstractBrooklynObject;
+import org.apache.brooklyn.core.objs.AbstractConfigurationSupportInternal;
 import org.apache.brooklyn.util.collections.SetFromLiveMap;
 import org.apache.brooklyn.util.core.config.ConfigBag;
 import org.apache.brooklyn.util.core.flags.FlagUtils;
@@ -379,7 +380,7 @@ public abstract class AbstractLocation extends AbstractBrooklynObject
implements
         return subscriptions;
     }
 
-    private class BasicConfigurationSupport implements ConfigurationSupportInternal {
+    private class BasicConfigurationSupport extends AbstractConfigurationSupportInternal
{
 
         @Override
         public <T> T get(ConfigKey<T> key) {
@@ -397,11 +398,6 @@ public abstract class AbstractLocation extends AbstractBrooklynObject
implements
         }
 
         @Override
-        public <T> T get(HasConfigKey<T> key) {
-            return get(key.getConfigKey());
-        }
-
-        @Override
         public <T> T set(ConfigKey<T> key, T val) {
             T result = configBag.put(key, val);
             onChanged();
@@ -409,23 +405,12 @@ public abstract class AbstractLocation extends AbstractBrooklynObject
implements
         }
 
         @Override
-        public <T> T set(HasConfigKey<T> key, T val) {
-            return set(key.getConfigKey(), val);
-        }
-
-        @Override
         public <T> T set(ConfigKey<T> key, Task<T> val) {
             // TODO Support for locations
             throw new UnsupportedOperationException();
         }
 
         @Override
-        public <T> T set(HasConfigKey<T> key, Task<T> val) {
-            // TODO Support for locations
-            throw new UnsupportedOperationException();
-        }
-
-        @Override
         public ConfigBag getBag() {
             ConfigBag result = ConfigBag.newInstanceExtending(configBag, ImmutableMap.of());
             Location p = getParent();
@@ -446,22 +431,12 @@ public abstract class AbstractLocation extends AbstractBrooklynObject
implements
         }
 
         @Override
-        public Maybe<Object> getRaw(HasConfigKey<?> key) {
-            return getRaw(key.getConfigKey());
-        }
-
-        @Override
         public Maybe<Object> getLocalRaw(ConfigKey<?> key) {
             if (hasConfig(key, false)) return Maybe.of(getLocalBag().getStringKey(key.getName()));
             return Maybe.absent();
         }
 
         @Override
-        public Maybe<Object> getLocalRaw(HasConfigKey<?> key) {
-            return getLocalRaw(key.getConfigKey());
-        }
-
-        @Override
         public void addToLocalBag(Map<String, ?> vals) {
             configBag.putAll(vals);
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f9b9e1f/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java
b/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java
new file mode 100644
index 0000000..4caa7e6
--- /dev/null
+++ b/core/src/main/java/org/apache/brooklyn/core/objs/AbstractConfigurationSupportInternal.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.brooklyn.core.objs;
+
+import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.config.ConfigKey.HasConfigKey;
+import org.apache.brooklyn.util.guava.Maybe;
+
+public abstract class AbstractConfigurationSupportInternal implements BrooklynObjectInternal.ConfigurationSupportInternal
{
+
+    @Override
+    public <T> T get(HasConfigKey<T> key) {
+        return get(key.getConfigKey());
+    }
+
+    @Override
+    public Maybe<Object> getLocalRaw(HasConfigKey<?> key) {
+        return getLocalRaw(key.getConfigKey());
+    }
+
+    @Override
+    public Maybe<Object> getRaw(HasConfigKey<?> key) {
+        return getRaw(key.getConfigKey());
+    }
+
+    @Override
+    public <T> T set(HasConfigKey<T> key, Task<T> val) {
+        return set(key.getConfigKey(), val);
+    }
+
+    @Override
+    public <T> T set(HasConfigKey<T> key, T val) {
+        return set(key.getConfigKey(), val);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f9b9e1f/core/src/main/java/org/apache/brooklyn/core/objs/AbstractEntityAdjunct.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/objs/AbstractEntityAdjunct.java b/core/src/main/java/org/apache/brooklyn/core/objs/AbstractEntityAdjunct.java
index 3434471..25c58ad 100644
--- a/core/src/main/java/org/apache/brooklyn/core/objs/AbstractEntityAdjunct.java
+++ b/core/src/main/java/org/apache/brooklyn/core/objs/AbstractEntityAdjunct.java
@@ -41,7 +41,6 @@ import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.api.sensor.Sensor;
 import org.apache.brooklyn.api.sensor.SensorEventListener;
 import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.config.ConfigKey.HasConfigKey;
 import org.apache.brooklyn.config.ConfigMap;
 import org.apache.brooklyn.core.config.ConfigKeys;
 import org.apache.brooklyn.core.enricher.AbstractEnricher;
@@ -289,18 +288,13 @@ public abstract class AbstractEntityAdjunct extends AbstractBrooklynObject
imple
         }
     }
     
-    private class BasicConfigurationSupport implements ConfigurationSupportInternal {
+    private class BasicConfigurationSupport extends AbstractConfigurationSupportInternal
{
 
         @Override
         public <T> T get(ConfigKey<T> key) {
             return configsInternal.getConfig(key);
         }
 
-        @Override
-        public <T> T get(HasConfigKey<T> key) {
-            return get(key.getConfigKey());
-        }
-
         @SuppressWarnings("unchecked")
         @Override
         public <T> T set(ConfigKey<T> key, T val) {
@@ -312,11 +306,6 @@ public abstract class AbstractEntityAdjunct extends AbstractBrooklynObject
imple
             return result;
         }
 
-        @Override
-        public <T> T set(HasConfigKey<T> key, T val) {
-            return setConfig(key.getConfigKey(), val);
-        }
-
         @SuppressWarnings("unchecked")
         @Override
         public <T> T set(ConfigKey<T> key, Task<T> val) {
@@ -330,11 +319,6 @@ public abstract class AbstractEntityAdjunct extends AbstractBrooklynObject
imple
         }
 
         @Override
-        public <T> T set(HasConfigKey<T> key, Task<T> val) {
-            return set(key.getConfigKey(), val);
-        }
-
-        @Override
         public ConfigBag getBag() {
             return getLocalBag();
         }
@@ -350,21 +334,11 @@ public abstract class AbstractEntityAdjunct extends AbstractBrooklynObject
imple
         }
 
         @Override
-        public Maybe<Object> getRaw(HasConfigKey<?> key) {
-            return getRaw(key.getConfigKey());
-        }
-
-        @Override
         public Maybe<Object> getLocalRaw(ConfigKey<?> key) {
             return configsInternal.getConfigRaw(key, false);
         }
 
         @Override
-        public Maybe<Object> getLocalRaw(HasConfigKey<?> key) {
-            return getLocalRaw(key.getConfigKey());
-        }
-
-        @Override
         public void addToLocalBag(Map<String, ?> vals) {
             configsInternal.addToLocalBag(vals);
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f9b9e1f/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java
b/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java
index d076f4e..257da5a 100644
--- a/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java
+++ b/core/src/main/java/org/apache/brooklyn/core/objs/BrooklynObjectInternal.java
@@ -74,7 +74,7 @@ public interface BrooklynObjectInternal extends BrooklynObject, Rebindable
{
         Maybe<Object> getRaw(ConfigKey<?> key);
 
         /**
-         * @see {@link #getConfigRaw(ConfigKey)}
+         * @see {@link #getRaw(ConfigKey)}
          */
         @Beta
         Maybe<Object> getRaw(HasConfigKey<?> key);
@@ -87,7 +87,7 @@ public interface BrooklynObjectInternal extends BrooklynObject, Rebindable
{
         Maybe<Object> getLocalRaw(ConfigKey<?> key);
 
         /**
-         * @see {@link #getLocalConfigRaw(ConfigKey)}
+         * @see {@link #getLocalRaw(ConfigKey)}
          */
         @Beta
         Maybe<Object> getLocalRaw(HasConfigKey<?> key);


Mime
View raw message