Brooklyn

brooklyn.event.basic
[Java] Class AttributeSensorAndConfigKey

java.lang.Object
  brooklyn.event.basic.BasicSensor
      brooklyn.event.basic.BasicAttributeSensor
          brooklyn.event.basic.AttributeSensorAndConfigKey
All Implemented Interfaces:
HasConfigKey

@SuppressWarnings("deprecation")
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.


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, hashCode, newEvent, toString
 

Constructor Detail

AttributeSensorAndConfigKey

public AttributeSensorAndConfigKey(java.lang.Class configType, java.lang.Class sensorType, java.lang.String name)


AttributeSensorAndConfigKey

public AttributeSensorAndConfigKey(java.lang.Class configType, java.lang.Class sensorType, java.lang.String name, java.lang.String description)


AttributeSensorAndConfigKey

public AttributeSensorAndConfigKey(java.lang.Class configType, java.lang.Class sensorType, java.lang.String name, java.lang.String description, java.lang.Object defaultValue)


AttributeSensorAndConfigKey

public AttributeSensorAndConfigKey(AttributeSensorAndConfigKey orig, ConfigType defaultValue)


 
Method Detail

convertConfigToSensor

protected SensorType convertConfigToSensor(ConfigType value, Entity entity)
converts the given ConfigType value to the corresponding SensorType value, with respect to the given 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


getAsSensorValue

public 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

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 instead for single-execution calls. the framework calls this from AbstractEntity#setAttribute(AttributeSensorAndConfigKey)#setAttribute(AttributeSensorAndConfigKey) typically via ConfigSensorAdapter#apply()#apply() e.g. from SoftwareProcessEntity.preStart.)


getConfigKey

public ConfigKey getConfigKey()


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.