public class InvokeEffectorOnCollectionSensorChange extends AbstractInvokeEffectorPolicy implements SensorEventListener<java.util.Collection<?>>
AttributeSensor
and invokes the named
effectors for each element that was added and removed.
The policy only detects replacements of the collection; it does not act on
modifications. If the sensor has value A
and an element is added –
value A'
– the on-added effector is not invoked. If the sensor is
later set to B
the delta is made between A
and B
,
not A'
and B
.
To simplify the detection of additions and removals the collection is converted to a
Set
. This means that only a single event will fire for duplicate elements in
the collection. Null values for the sensor are considered an empty collection.
The effectors are provided the elements that changed in their parameter map. If the
sensor is a collection of maps the elements are provided with their keys coerced to
strings and their values unchanged. Otherwise the elements are provided in a
single-entry map keyed by the value for PARAMETER_NAME
.
Effectors are asynchronous. If elements are added and removed in quick succession there are no guarantees that the `onAdded' task will have finished before the corresponding `onRemoved' task is invoked.
AbstractEntityAdjunct.AdjunctTagSupport, AbstractEntityAdjunct.BasicSubscriptionSupport
BrooklynObject.RelationSupport<T extends BrooklynObject>, BrooklynObject.SubscriptionSupport, BrooklynObject.TagSupport
Configurable.ConfigurationSupport
BrooklynObjectInternal.ConfigurationSupportInternal, BrooklynObjectInternal.RelationSupportInternal<T extends BrooklynObject>, BrooklynObjectInternal.SubscriptionSupportInternal
Modifier and Type | Field and Description |
---|---|
static ConfigKey<java.lang.String> |
ON_ADDED_EFFECTOR_NAME |
static ConfigKey<java.lang.String> |
ON_REMOVED_EFFECTOR_NAME |
static ConfigKey<java.lang.String> |
PARAMETER_NAME |
static ConfigKey<AttributeSensor<? extends java.util.Collection<?>>> |
TRIGGER_SENSOR |
IS_BUSY_SENSOR_NAME
HIGHLIGHT_NAME_LAST_ACTION, HIGHLIGHT_NAME_LAST_CONFIRMATION, HIGHLIGHT_NAME_LAST_VIOLATION, HIGHLIGHT_NAME_TRIGGERS
NOOP
Constructor and Description |
---|
InvokeEffectorOnCollectionSensorChange() |
Modifier and Type | Method and Description |
---|---|
void |
onEvent(SensorEvent<java.util.Collection<?>> event)
The
SensorEvent handler method. |
void |
setEntity(EntityLocal entity) |
destroy, getPolicyType, getRebindSupport, isRunning, isSuspended, relations, resume, suspend, toString
config, configure, getAdjunctType, getConfig, getDisplayName, getEntity, getExecutionContext, getHighlights, getManagementContext, getUniqueTag, isDestroyed, setDisplayName, setHighlights, subscriptions, tags
addSearchPath, getCatalogItemId, getCatalogItemIdSearchPath, getId, init, rebind, setCatalogItemId, setCatalogItemIdAndSearchPath, setManagementContext, stackCatalogItemId
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getHighlights, getUniqueTag, isDestroyed
getCatalogItemId, getCatalogItemIdSearchPath, getDisplayName, subscriptions, tags
config, getConfig
addSearchPath, setCatalogItemId, setCatalogItemIdAndSearchPath, stackCatalogItemId
public static final ConfigKey<AttributeSensor<? extends java.util.Collection<?>>> TRIGGER_SENSOR
public static final ConfigKey<java.lang.String> ON_ADDED_EFFECTOR_NAME
public static final ConfigKey<java.lang.String> ON_REMOVED_EFFECTOR_NAME
public static final ConfigKey<java.lang.String> PARAMETER_NAME
public InvokeEffectorOnCollectionSensorChange()
public void setEntity(EntityLocal entity)
setEntity
in class AbstractInvokeEffectorPolicy
public void onEvent(SensorEvent<java.util.Collection<?>> event)
SensorEventListener
SensorEvent
handler method.onEvent
in interface SensorEventListener<java.util.Collection<?>>