|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrooklyn.event.basic.BasicSensor
brooklyn.event.basic.BasicAttributeSensor
brooklyn.event.basic.AttributeSensorAndConfigKey
public abstract class AttributeSensorAndConfigKey extends BasicAttributeSensor
A Sensor describing an attribute that can be configured with inputs that are used to derive the final value.
The ConfigKey will have the same name and description as the sensor but not necessarily the same type. Conversion to set the sensor value from the config key must be supplied in a subclass.
ConfigToAttributes#apply(EntityLocal, AttributeSensorAndConfigKey)#apply(EntityLocal, AttributeSensorAndConfigKey) is useful to set the attribute from the sensor.
Constructor Summary | |
AttributeSensorAndConfigKey(java.lang.Class configType, java.lang.Class sensorType, java.lang.String name)
|
|
AttributeSensorAndConfigKey(java.lang.Class configType, java.lang.Class sensorType, java.lang.String name, java.lang.String description)
|
|
AttributeSensorAndConfigKey(java.lang.Class configType, java.lang.Class sensorType, java.lang.String name, java.lang.String description, java.lang.Object defaultValue)
|
|
AttributeSensorAndConfigKey(AttributeSensorAndConfigKey orig, ConfigType defaultValue)
|
Method Summary | |
---|---|
protected SensorType
|
convertConfigToSensor(ConfigType value, Entity entity)
converts the given ConfigType value to the corresponding SensorType value, with respect to the given entity |
SensorType
|
getAsSensorValue(Entity e)
returns the sensor value for this attribute on the given entity, if present, otherwise works out what the sensor value should be based on the config key's value |
ConfigKey
|
getConfigKey()
|
Methods inherited from class BasicSensor | |
---|---|
equals, getDescription, getName, getNameParts, getType, getTypeName, getTypeToken, hashCode, newEvent, toString |
Constructor Detail |
---|
public AttributeSensorAndConfigKey(java.lang.Class configType, java.lang.Class sensorType, java.lang.String name)
public AttributeSensorAndConfigKey(java.lang.Class configType, java.lang.Class sensorType, java.lang.String name, java.lang.String description)
public AttributeSensorAndConfigKey(java.lang.Class configType, java.lang.Class sensorType, java.lang.String name, java.lang.String description, java.lang.Object defaultValue)
public AttributeSensorAndConfigKey(AttributeSensorAndConfigKey orig, ConfigType defaultValue)
Method Detail |
---|
protected SensorType convertConfigToSensor(ConfigType value, Entity entity)
this is invoked after checks whether the entity already has a value for the sensor, and the entity-specific config value is passed for convenience if set, otherwise the config key default value is passed for convenience
this message should be allowed to return null if the conversion cannot be completed at this time
public SensorType getAsSensorValue(Entity e)
calls to this may allocate resources (e.g. ports) so should be called only once and then (if non-null) assigned as the sensor's value
(for this reason this method should generally not be invoked by callers except in tests and by the framework, and similarly should not be overridden; implement convertConfigToSensor(Object, Entity) instead for single-execution calls. the framework calls this from AbstractEntity#setAttribute(AttributeSensorAndConfigKey)#setAttribute(AttributeSensorAndConfigKey) typically via ConfigToAttributes#apply(EntityLocal)#apply(EntityLocal) e.g. from SoftwareProcessImpl.preStart().)
public ConfigKey getConfigKey()
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.