Brooklyn

brooklyn.entity.basic
[Groovy] Class AbstractEntity

java.lang.Object
  groovy.lang.GroovyObjectSupport
      brooklyn.entity.basic.AbstractEntity
All Implemented Interfaces:
EntityLocal, groovy.lang.GroovyInterceptable

abstract class AbstractEntity
extends groovy.lang.GroovyObjectSupport

Default Entity implementation. Provides several common fields (name, id); a map config which contains arbitrary config data; sensors and effectors; policies; managementContext.

Fields in config can be accessed (get and set) without referring to config, (through use of propertyMissing). Note that config is typically inherited by children, whereas the fields are not. (Attributes cannot be so accessed, nor are they inherited.)


Field Summary
protected static Logger LOG

static BasicNotificationSensor SENSOR_ADDED

static BasicNotificationSensor SENSOR_REMOVED

protected SubscriptionTracker _subscriptionTracker

protected EntityReference application

protected AttributeMap attributesInternal

The sensor-attribute values of this entity.

protected ConfigMap configsInternal

The config values of this entity.

protected ExecutionContext execution

protected ManagementContext managementContext

java.lang.Object managementData

Field for use only by management plane, to record remote destination when proxied.

protected SubscriptionContext subscription

protected java.util.Map tempWorkings

For temporary data, e.g. timestamps etc for calculating real attribute values, such as when calculating averages over time etc.

 
Property Summary
java.lang.String displayName

java.util.Collection enrichers

EntityCollectionReference groups

java.lang.String id

java.util.Collection locations

EntityCollectionReference ownedChildren

EntityReference owner

java.util.Collection policies

java.util.Map presentationAttributes

boolean previouslyOwned

 
Constructor Summary
AbstractEntity(Entity owner)

AbstractEntity(java.util.Map flags = [:], Entity owner = null)

 
Method Summary
void addEnricher(AbstractEnricher enricher)

void addGroup(Group e)

Adds this as a member of the given group, registers with application if necessary

Entity addOwnedChild(Entity child)

Adds the given entity as a member of this group and this group as one of the groups of the child; returns argument passed in, for convenience.

void addPolicy(AbstractPolicy policy)

protected void assertNotYetOwned()

void clearOwner()

Entity configure(java.util.Map flags = [:])

sets fields from flags; can be overridden if needed, subclasses should set custom fields before _invoking_ this super (and they nearly always should invoke the super)

Entity configure(ConfigKey key, java.lang.Object value)

Sets a config key value, and returns this Entity instance for use in fluent-API style coding.

void destroy()

Should be invoked at end-of-life to clean up the item.

void emit(Sensor sensor, java.lang.Object val)

void emitInternal(Sensor sensor, java.lang.Object val)

Location firstLocation()

java.util.Map getAllConfig()

Application getApplication()

Returns the application, looking it up if not yet known (registering if necessary)

java.lang.String getApplicationId()

java.lang.Object getAttribute(AttributeSensor attribute)

java.lang.Object getAttributeByNameParts(java.util.List nameParts)

java.lang.Object getConfig(ConfigKey key)

java.lang.Object getConfig(HasConfigKey key)

java.lang.Object getConfig(HasConfigKey key, java.lang.Object defaultValue)

java.lang.Object getConfig(ConfigKey key, java.lang.Object defaultValue)

ConfigMap getConfigMap()

Effector getEffector(java.lang.String effectorName)

Convenience for finding named effector in getEffectors() java.util.Map.

java.util.Collection getEnrichers()

EntityType getEntityType()

ExecutionContext getExecutionContext()

java.util.Collection getGroups()

java.util.Collection getLocations()

ManagementContext getManagementContext()

protected EntityDynamicType getMutableEntityType()

java.util.Collection getOwnedChildren()

Entity getOwner()

java.util.Collection getPolicies()

SubscriptionContext getSubscriptionContext()

protected SubscriptionTracker getSubscriptionTracker()

boolean hasEverBeenManaged()

void invalidate()

For use by management plane, to invalidate all fields (e.g. when an entity is changing to being proxied)

Task invoke(java.util.Map parameters = [:], Effector eff)

Invoke an Effector directly.

Task invoke(Effector eff, java.util.Map parameters)

Additional form supplied for when the parameter map needs to be made explicit.

Task invokeFromJava(java.util.Map parameters = [:], Effector eff)

TODO Calling the above groovy method from java gives compilation error due to use of generics This method will be removed once that is resolved in groovy (or when this is converted to pure java).

java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)

Called by groovy for all method invocations; pass-through for everything but effectors; effectors get wrapped in a new task (parented by current task if there is one).

void onManagementBecomingMaster()

Invoked by ManagementContext when this entity becomes managed at a particular management node, including the initial management started and subsequent management node master-change for this entity.

void onManagementNoLongerMaster()

Invoked by ManagementContext when this entity becomes mastered at a particular management node, including the final management end and subsequent management node master-change for this entity.

void refreshInheritedConfig()

void refreshInheritedConfigOfChildren()

boolean removeAllEnrichers()

boolean removeAllPolicies()

void removeAttribute(AttributeSensor attribute)

boolean removeEnricher(AbstractEnricher enricher)

boolean removeOwnedChild(Entity child)

boolean removePolicy(AbstractPolicy policy)

protected void setApplication(Application app)

java.lang.Object setAttribute(AttributeSensor attribute, java.lang.Object val)

java.lang.Object setAttribute(AttributeSensorAndConfigKey configuredSensor)

sets the value of the given attribute sensor from the config key value herein, if the config key resolves to a non-null value as a sensor

void setBeingManaged()

java.lang.Object setConfig(ConfigKey key, java.lang.Object val)

java.lang.Object setConfig(HasConfigKey key, java.lang.Object val)

protected java.lang.Object setConfigEvenIfOwned(ConfigKey key, java.lang.Object val)

protected java.lang.Object setConfigEvenIfOwned(HasConfigKey key, java.lang.Object val)

protected void setConfigIfValNonNull(ConfigKey key, java.lang.Object val)

protected void setConfigIfValNonNull(HasConfigKey key, java.lang.Object val)

AbstractEntity setOwner(Entity entity)

Adds this as a member of the given group, registers with application if necessary

SubscriptionHandle subscribe(Entity producer, Sensor sensor, SensorEventListener listener)

@see EntityLocal#subscribe

SubscriptionHandle subscribeToChildren(Entity parent, Sensor sensor, SensorEventListener listener)

@see EntityLocal#subscribeToChildren

SubscriptionHandle subscribeToMembers(Group group, Sensor sensor, SensorEventListener listener)

@see EntityLocal#subscribeToMembers

java.lang.String toString()

Default String representation is simplified name of class, together with selected fields.

java.util.Collection toStringFieldsToInclude()

override this, adding to the collection, to supply fields whose value, if not null, should be included in the toString

protected boolean unsubscribe(Entity producer)

Unsubscribes the given producer.

protected boolean unsubscribe(Entity producer, SubscriptionHandle handle)

Unsubscribes the given handle.

 
Methods inherited from class groovy.lang.GroovyObjectSupport
groovy.lang.GroovyObjectSupport#setProperty(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#getProperty(java.lang.String), groovy.lang.GroovyObjectSupport#getMetaClass(), groovy.lang.GroovyObjectSupport#setMetaClass(groovy.lang.MetaClass), groovy.lang.GroovyObjectSupport#invokeMethod(java.lang.String, java.lang.Object), groovy.lang.GroovyObjectSupport#wait(), groovy.lang.GroovyObjectSupport#wait(long), groovy.lang.GroovyObjectSupport#wait(long, int), groovy.lang.GroovyObjectSupport#equals(java.lang.Object), groovy.lang.GroovyObjectSupport#toString(), groovy.lang.GroovyObjectSupport#hashCode(), groovy.lang.GroovyObjectSupport#getClass(), groovy.lang.GroovyObjectSupport#notify(), groovy.lang.GroovyObjectSupport#notifyAll()
 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

LOG

protected static final Logger LOG


SENSOR_ADDED

public static BasicNotificationSensor SENSOR_ADDED


SENSOR_REMOVED

public static BasicNotificationSensor SENSOR_REMOVED


_subscriptionTracker

protected SubscriptionTracker _subscriptionTracker


application

protected EntityReference application


attributesInternal

protected final AttributeMap attributesInternal
The sensor-attribute values of this entity. Updating this map should be done via getAttribute/setAttribute; it will automatically emit an attribute-change event.


configsInternal

protected final ConfigMap configsInternal
The config values of this entity. Updating this map should be done via getConfig/setConfig.


execution

protected ExecutionContext execution


managementContext

protected ManagementContext managementContext


managementData

public java.lang.Object managementData
Field for use only by management plane, to record remote destination when proxied.


subscription

protected SubscriptionContext subscription


tempWorkings

protected final java.util.Map tempWorkings
For temporary data, e.g. timestamps etc for calculating real attribute values, such as when calculating averages over time etc.


 
Property Detail

displayName

java.lang.String displayName


enrichers

java.util.Collection enrichers


groups

final EntityCollectionReference groups


id

final java.lang.String id


locations

java.util.Collection locations


ownedChildren

final EntityCollectionReference ownedChildren


owner

EntityReference owner


policies

java.util.Collection policies


presentationAttributes

java.util.Map presentationAttributes


previouslyOwned

boolean previouslyOwned


 
Constructor Detail

AbstractEntity

AbstractEntity(Entity owner)


AbstractEntity

AbstractEntity(java.util.Map flags = [:], Entity owner = null)


 
Method Detail

addEnricher

@Override
void addEnricher(AbstractEnricher enricher)


addGroup

@Override
void addGroup(Group e)
Adds this as a member of the given group, registers with application if necessary


addOwnedChild

@Override
Entity addOwnedChild(Entity child)
Adds the given entity as a member of this group and this group as one of the groups of the child; returns argument passed in, for convenience.


addPolicy

@Override
void addPolicy(AbstractPolicy policy)


assertNotYetOwned

protected void assertNotYetOwned()


clearOwner

void clearOwner()


configure

Entity configure(java.util.Map flags = [:])
sets fields from flags; can be overridden if needed, subclasses should set custom fields before _invoking_ this super (and they nearly always should invoke the super)

note that it is usually preferred to use the SetFromFlag annotation on relevant fields so they get set automatically by this method and overriding it is unnecessary

Returns:
this entity, for fluent style initialization


configure

Entity configure(ConfigKey key, java.lang.Object value)
Sets a config key value, and returns this Entity instance for use in fluent-API style coding.


destroy

void destroy()
Should be invoked at end-of-life to clean up the item.


emit

@Override
void emit(Sensor sensor, java.lang.Object val)


emitInternal

@Override
void emitInternal(Sensor sensor, java.lang.Object val)


firstLocation

Location firstLocation()


getAllConfig

java.util.Map getAllConfig()


getApplication

@Override
Application getApplication()
Returns the application, looking it up if not yet known (registering if necessary)


getApplicationId

@Override
java.lang.String getApplicationId()


getAttribute

@Override
java.lang.Object getAttribute(AttributeSensor attribute)


getAttributeByNameParts

java.lang.Object getAttributeByNameParts(java.util.List nameParts)


getConfig

@Override
java.lang.Object getConfig(ConfigKey key)


getConfig

@Override
java.lang.Object getConfig(HasConfigKey key)


getConfig

@Override
java.lang.Object getConfig(HasConfigKey key, java.lang.Object defaultValue)


getConfig

@Override
java.lang.Object getConfig(ConfigKey key, java.lang.Object defaultValue)


getConfigMap

ConfigMap getConfigMap()


getEffector

Effector getEffector(java.lang.String effectorName)
Convenience for finding named effector in getEffectors() java.util.Map.


getEnrichers

@Override
java.util.Collection getEnrichers()


getEntityType

@Override
EntityType getEntityType()


getExecutionContext

ExecutionContext getExecutionContext()


getGroups

@Override
java.util.Collection getGroups()


getLocations

@Override
java.util.Collection getLocations()


getManagementContext

@Override
ManagementContext getManagementContext()


getMutableEntityType

protected EntityDynamicType getMutableEntityType()


getOwnedChildren

@Override
java.util.Collection getOwnedChildren()


getOwner

@Override
Entity getOwner()


getPolicies

@Override
java.util.Collection getPolicies()


getSubscriptionContext

SubscriptionContext getSubscriptionContext()


getSubscriptionTracker

protected SubscriptionTracker getSubscriptionTracker()


hasEverBeenManaged

boolean hasEverBeenManaged()


invalidate

void invalidate()
For use by management plane, to invalidate all fields (e.g. when an entity is changing to being proxied)


invoke

Task invoke(java.util.Map parameters = [:], Effector eff)
Invoke an Effector directly.


invoke

Task invoke(Effector eff, java.util.Map parameters)
Additional form supplied for when the parameter map needs to be made explicit.
See Also:
invoke(Effector)


invokeFromJava

Task invokeFromJava(java.util.Map parameters = [:], Effector eff)
TODO Calling the above groovy method from java gives compilation error due to use of generics This method will be removed once that is resolved in groovy (or when this is converted to pure java).


invokeMethod

java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
Called by groovy for all method invocations; pass-through for everything but effectors; effectors get wrapped in a new task (parented by current task if there is one).


onManagementBecomingMaster

void onManagementBecomingMaster()
Invoked by ManagementContext when this entity becomes managed at a particular management node, including the initial management started and subsequent management node master-change for this entity.


onManagementNoLongerMaster

void onManagementNoLongerMaster()
Invoked by ManagementContext when this entity becomes mastered at a particular management node, including the final management end and subsequent management node master-change for this entity.


refreshInheritedConfig

void refreshInheritedConfig()


refreshInheritedConfigOfChildren

void refreshInheritedConfigOfChildren()


removeAllEnrichers

@Override
boolean removeAllEnrichers()


removeAllPolicies

@Override
boolean removeAllPolicies()


removeAttribute

@Override
void removeAttribute(AttributeSensor attribute)


removeEnricher

@Override
boolean removeEnricher(AbstractEnricher enricher)


removeOwnedChild

@Override
boolean removeOwnedChild(Entity child)


removePolicy

@Override
boolean removePolicy(AbstractPolicy policy)


setApplication

protected void setApplication(Application app)


setAttribute

@Override
java.lang.Object setAttribute(AttributeSensor attribute, java.lang.Object val)


setAttribute

java.lang.Object setAttribute(AttributeSensorAndConfigKey configuredSensor)
sets the value of the given attribute sensor from the config key value herein, if the config key resolves to a non-null value as a sensor

returns old value


setBeingManaged

void setBeingManaged()


setConfig

@Override
java.lang.Object setConfig(ConfigKey key, java.lang.Object val)


setConfig

@Override
java.lang.Object setConfig(HasConfigKey key, java.lang.Object val)


setConfigEvenIfOwned

protected java.lang.Object setConfigEvenIfOwned(ConfigKey key, java.lang.Object val)


setConfigEvenIfOwned

protected java.lang.Object setConfigEvenIfOwned(HasConfigKey key, java.lang.Object val)


setConfigIfValNonNull

protected void setConfigIfValNonNull(ConfigKey key, java.lang.Object val)


setConfigIfValNonNull

protected void setConfigIfValNonNull(HasConfigKey key, java.lang.Object val)


setOwner

AbstractEntity setOwner(Entity entity)
Adds this as a member of the given group, registers with application if necessary


subscribe

SubscriptionHandle subscribe(Entity producer, Sensor sensor, SensorEventListener listener)
See Also:
EntityLocal#subscribe#subscribe


subscribeToChildren

SubscriptionHandle subscribeToChildren(Entity parent, Sensor sensor, SensorEventListener listener)
See Also:
EntityLocal#subscribeToChildren#subscribeToChildren


subscribeToMembers

SubscriptionHandle subscribeToMembers(Group group, Sensor sensor, SensorEventListener listener)
See Also:
EntityLocal#subscribeToMembers#subscribeToMembers


toString

@Override
java.lang.String toString()
Default String representation is simplified name of class, together with selected fields.


toStringFieldsToInclude

java.util.Collection toStringFieldsToInclude()
override this, adding to the collection, to supply fields whose value, if not null, should be included in the toString


unsubscribe

protected boolean unsubscribe(Entity producer)
Unsubscribes the given producer.
See Also:
SubscriptionContext#unsubscribe(SubscriptionHandle)#unsubscribe(SubscriptionHandle)


unsubscribe

protected boolean unsubscribe(Entity producer, SubscriptionHandle handle)
Unsubscribes the given handle.
See Also:
SubscriptionContext#unsubscribe(SubscriptionHandle)#unsubscribe(SubscriptionHandle)


 

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