public BasicConfigKeyOverwriting(ConfigKey<T> key, T defaultValue) { super(checkNotNull(key.getTypeToken(), "type"), checkNotNull(key.getName(), "name"), key.getDescription(), defaultValue); parentKey = key; }
/** @deprecated since 0.6.0; use {@link ConfigKeys#newConfigKeyWithDefault(ConfigKey, Object)} */ public BasicConfigKey(ConfigKey<T> key, T defaultValue) { log.warn("deprecated use of BasicConfigKey(exendedKey) constructor, for "+key+" ("+defaultValue+")"); this.description = key.getDescription(); this.name = checkNotNull(key.getName(), "name"); this.typeToken = checkNotNull(key.getTypeToken(), "type"); this.type = checkNotNull(key.getType(), "type"); this.defaultValue = defaultValue; this.reconfigurable = false; }
/** removes the given prefix from the key for configuration purposes; logs warning and does nothing if there is no such prefix. * prefix will typically end with a ".". * this is useful for configuration purposes when a subsystem uses a short-name config (e.g. "user") * but in entity config or at the root (brooklyn.properties) there are longer names (e.g. "brooklyn.ssh.config.user"), * and we wish to convert from the longer names to the short-name. */ public static <T> ConfigKey<T> unprefixedKey(String prefix, ConfigKey<T> key) { String newName = key.getName(); if (newName.startsWith(prefix)) newName = newName.substring(prefix.length()); else log.warn("Cannot remove prefix "+prefix+" from key "+key+" (ignoring)"); return new BasicConfigKey<T>(key.getTypeToken(), newName, key.getDescription(), key.getDefaultValue()); }
public static PolicyConfigSummary policyConfigSummary(BrooklynRestResourceUtils utils, EntityLocal entity, Policy policy, ConfigKey<?> config) { String applicationUri = "/v1/applications/" + entity.getApplicationId(); String entityUri = applicationUri + "/entities/" + entity.getId(); String policyUri = entityUri + "/policies/" + policy.getId(); Map<String, URI> links = ImmutableMap.<String, URI>builder() .put("self", URI.create(policyUri + "/config/" + config.getName())) .put("application", URI.create(applicationUri)) .put("entity", URI.create(entityUri)) .put("policy", URI.create(policyUri)) .build(); return new PolicyConfigSummary(config.getName(), config.getTypeName(), config.getDescription(), PolicyConfigResource.getStringValueForDisplay(utils, policy, config.getDefaultValue()), config.isReconfigurable(), links); }
public static <T> ConfigKey<T> newConfigKeyRenamed(String newName, ConfigKey<T> key) { return new BasicConfigKey<T>(key.getTypeToken(), newName, key.getDescription(), key.getDefaultValue()); }
protected EntityConfigSummary(ConfigKey<?> config, String label, Double priority, Map<String, URI> links) { super(config.getName(), config.getTypeName(), config.getDescription(), JsonUtils.toJsonable(config.getDefaultValue()), config.isReconfigurable(), label, priority); this.links = links==null ? null : ImmutableMap.copyOf(links); }
protected ConfigSummary(ConfigKey<?> config) { this.name = config.getName(); this.type = config.getTypeName(); this.description = config.getDescription(); this.reconfigurable = config.isReconfigurable(); /* Use String, to guarantee it is serializable; otherwise get: * No serializer found for class brooklyn.policy.autoscaling.AutoScalerPolicy$3 and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS) ) (through reference chain: java.util.ArrayList[9]->brooklyn.rest.domain.PolicyConfigSummary["defaultValue"]) * at org.codehaus.jackson.map.ser.impl.UnknownSerializer.failForEmpty(UnknownSerializer.java:52) */ this.defaultValue = (config.getDefaultValue() == null) ? null : config.getDefaultValue().toString(); this.label = null; this.priority = null; }
protected ConfigSummary(ConfigKey<?> config, String label, Double priority) { this.name = config.getName(); this.description = config.getDescription(); this.reconfigurable = config.isReconfigurable();
@SuppressWarnings({ "unchecked", "rawtypes" }) public <V> EffectorBuilder<T> parameter(ConfigKey<V> key) { return parameter(new BasicParameterType<V>(key.getName(), (Class)key.getType(), key.getDescription(), key.getDefaultValue())); } public EffectorBuilder<T> parameter(ParameterType<?> p) {