You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2015/02/18 12:32:07 UTC
[2/9] incubator-brooklyn git commit: config: cleanup usage + deprecate
config: cleanup usage + deprecate
- Deprecates ConfigMap.getConfig(HasConfigKey, defaultVal) and
ConfigMap.getConfig(ConfigKey, defaultVal).
- Remove more usages of deprecated methods
- Declare
- EntityTransientCopyInternal: mark methods as deprecated, and adds
TODO about feeds() / config() which return objects that have mutator
methods.
- AbstractEntityAdjunct.configsInternal and .adjunctType: deprecate,
so can make private or change in future version.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/b944f83f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/b944f83f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/b944f83f
Branch: refs/heads/master
Commit: b944f83f67872e717c7cd66bdab93d7560dd65f3
Parents: b12e08d
Author: Aled Sage <al...@gmail.com>
Authored: Tue Feb 10 08:38:21 2015 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Feb 18 11:02:35 2015 +0000
----------------------------------------------------------------------
.../java/brooklyn/entity/basic/Entities.java | 7 ++---
.../basic/EntityTransientCopyInternal.java | 10 ++++---
.../location/basic/AbstractLocation.java | 2 +-
.../policy/basic/AbstractEntityAdjunct.java | 9 ++++++-
.../policy/autoscaling/AutoScalerPolicy.java | 2 +-
.../main/java/brooklyn/config/ConfigMap.java | 28 ++++++++++++++------
6 files changed, 40 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b944f83f/core/src/main/java/brooklyn/entity/basic/Entities.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/Entities.java b/core/src/main/java/brooklyn/entity/basic/Entities.java
index cdf1a01..f8fff24 100644
--- a/core/src/main/java/brooklyn/entity/basic/Entities.java
+++ b/core/src/main/java/brooklyn/entity/basic/Entities.java
@@ -42,6 +42,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import brooklyn.basic.BrooklynObjectInternal;
import brooklyn.config.BrooklynProperties;
import brooklyn.config.ConfigKey;
import brooklyn.config.ConfigKey.HasConfigKey;
@@ -316,7 +317,7 @@ public class Entities {
ConfigKey<?> realKey = e.getEntityType().getConfigKey(it.getName());
if (realKey!=null) it = realKey;
- Maybe<Object> mv = ((EntityInternal)e).getConfigMap().getConfigRaw(it, false);
+ Maybe<Object> mv = ((EntityInternal)e).config().getLocalRaw(it);
if (!isTrivial(mv)) {
Object v = mv.get();
out.append(currentIndentation+tab+tab+it.getName());
@@ -456,7 +457,7 @@ public class Entities {
out.append(currentIndentation+enr.toString()+"\n");
for (ConfigKey<?> key : sortConfigKeys(enr.getEnricherType().getConfigKeys())) {
- Maybe<Object> val = ((AbstractEnricher)enr).getConfigMap().getConfigRaw(key, true);
+ Maybe<Object> val = ((BrooklynObjectInternal)enr).config().getRaw(key);
if (!isTrivial(val)) {
out.append(currentIndentation+tab+tab+key);
out.append(" = ");
@@ -487,7 +488,7 @@ public class Entities {
out.append(currentIndentation+pol.toString()+"\n");
for (ConfigKey<?> key : sortConfigKeys(pol.getPolicyType().getConfigKeys())) {
- Maybe<Object> val = ((AbstractPolicy)pol).getConfigMap().getConfigRaw(key, true);
+ Maybe<Object> val = ((BrooklynObjectInternal)pol).config().getRaw(key);
if (!isTrivial(val)) {
out.append(currentIndentation+tab+tab+key);
out.append(" = ");
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b944f83f/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java b/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java
index ef2a9ee..14b9736 100644
--- a/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java
+++ b/core/src/main/java/brooklyn/entity/basic/EntityTransientCopyInternal.java
@@ -60,6 +60,8 @@ import com.google.common.annotations.Beta;
@Beta
public interface EntityTransientCopyInternal {
+ // TODO For feeds() and config(), need to ensure mutator methods on returned object are not invoked.
+
// from Entity
String getId();
@@ -95,11 +97,11 @@ public interface EntityTransientCopyInternal {
// from EntityInternal:
- EntityConfigMap getConfigMap();
- Map<ConfigKey<?>,Object> getAllConfig();
+ @Deprecated EntityConfigMap getConfigMap();
+ @Deprecated Map<ConfigKey<?>,Object> getAllConfig();
// for rebind mainly:
- ConfigBag getAllConfigBag();
- ConfigBag getLocalConfigBag();
+ @Deprecated ConfigBag getAllConfigBag();
+ @Deprecated ConfigBag getLocalConfigBag();
@SuppressWarnings("rawtypes")
Map<AttributeSensor, Object> getAllAttributes();
EntityManagementSupport getManagementSupport();
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b944f83f/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 9513cde..a576a60 100644
--- a/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
+++ b/core/src/main/java/brooklyn/location/basic/AbstractLocation.java
@@ -401,7 +401,7 @@ public abstract class AbstractLocation extends AbstractBrooklynObject implements
public ConfigBag getBag() {
ConfigBag result = ConfigBag.newInstanceExtending(configBag, ImmutableMap.of());
Location p = getParent();
- if (p!=null) result.putIfAbsent(((LocationInternal)p).config().getBag().getAllConfig());
+ if (p!=null) result.putIfAbsent(((LocationInternal)p).config().getBag());
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b944f83f/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java b/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java
index 4488560..bbd589d 100644
--- a/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java
+++ b/core/src/main/java/brooklyn/policy/basic/AbstractEntityAdjunct.java
@@ -82,10 +82,17 @@ public abstract class AbstractEntityAdjunct extends AbstractBrooklynObject imple
/**
* The config values of this entity. Updating this map should be done
- * via getConfig/setConfig.
+ * via {@link #config()}.
+ *
+ * @deprecated since 0.7.0; use {@link #config()} instead; this field may be made private or deleted in a future release.
*/
+ @Deprecated
protected final ConfigMapImpl configsInternal = new ConfigMapImpl(this);
+ /**
+ * @deprecated since 0.7.0; use {@link #getAdjunctType()} instead; this field may be made private or deleted in a future release.
+ */
+ @Deprecated
protected final AdjunctType adjunctType = new AdjunctType(this);
@SetFromFlag
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b944f83f/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java
----------------------------------------------------------------------
diff --git a/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java b/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java
index 835e9b7..8727f54 100644
--- a/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java
+++ b/policy/src/main/java/brooklyn/policy/autoscaling/AutoScalerPolicy.java
@@ -599,7 +599,7 @@ public class AutoScalerPolicy extends AbstractPolicy {
@Override
public void setEntity(EntityLocal entity) {
- if (!configsInternal.getConfigRaw(RESIZE_OPERATOR, true).isPresentAndNonNull()) {
+ if (!config().getRaw(RESIZE_OPERATOR).isPresentAndNonNull()) {
Preconditions.checkArgument(entity instanceof Resizable, "Provided entity must be an instance of Resizable, because no custom-resizer operator supplied");
}
super.setEntity(entity);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b944f83f/utils/common/src/main/java/brooklyn/config/ConfigMap.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/brooklyn/config/ConfigMap.java b/utils/common/src/main/java/brooklyn/config/ConfigMap.java
index c223b6e..eeb0fd0 100644
--- a/utils/common/src/main/java/brooklyn/config/ConfigMap.java
+++ b/utils/common/src/main/java/brooklyn/config/ConfigMap.java
@@ -29,14 +29,26 @@ public interface ConfigMap {
/** @see #getConfig(ConfigKey, Object), with default value as per the key, or null */
public <T> T getConfig(ConfigKey<T> key);
- /** @see #getConfig(ConfigKey, Object), with default value as per the key, or null */
+
+ /** @see #getConfig(ConfigKey, Object), with default value as per the key, or null */
public <T> T getConfig(HasConfigKey<T> key);
- /** @see #getConfig(ConfigKey, Object), with provided default value if not set */
+
+ /**
+ * @see #getConfig(ConfigKey, Object), with provided default value if not set
+ * @deprecated since 0.7.0; use {@link #getConfig(HasConfigKey)}
+ */
+ @Deprecated
public <T> T getConfig(HasConfigKey<T> key, T defaultValue);
- /** returns value stored against the given key,
+
+ /**
+ * Returns value stored against the given key,
* resolved (if it is a Task, possibly blocking), and coerced to the appropriate type,
* or given default value if not set,
- * unless the default value is null in which case it returns the default*/
+ * unless the default value is null in which case it returns the default.
+ *
+ * @deprecated since 0.7.0; use {@link #getConfig(ConfigKey)}
+ */
+ @Deprecated
public <T> T getConfig(ConfigKey<T> key, T defaultValue);
/** as {@link #getConfigRaw(ConfigKey)} but returning null if not present
@@ -46,13 +58,13 @@ public interface ConfigMap {
/** returns the value stored against the given key,
* <b>not</b> any default,
- * <b>not</b> resolved (and guaranteed non-blocking)
- * and <b>not</b> type-coerced
+ * <b>not</b> resolved (and guaranteed non-blocking),
+ * and <b>not</b> type-coerced.
* @param key key to look up
* @param includeInherited for {@link ConfigMap} instances which have an inheritance hierarchy,
- * whether to traverse it or not; has no effects where there is no inheritance
+ * whether to traverse it or not; has no effects where there is no inheritance
* @return raw, unresolved, uncoerced value of key in map,
- * but <b>not</b> any default on the key
+ * but <b>not</b> any default on the key
*/
public Maybe<Object> getConfigRaw(ConfigKey<?> key, boolean includeInherited);