|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Objectgroovy.lang.GroovyObjectSupport
brooklyn.entity.basic.AbstractEntity
abstract class AbstractEntity extends groovy.lang.GroovyObjectSupport
Default Entity implementation, which should be extended whenever implementing an entity.
Provides several common fields (name, id), and supports the core features of an entity such as configuration keys, attributes, subscriptions and effector invocation.
If a sub-class is creating other entities, this should be done in an overridden init() method.
Note that config is typically inherited by children, whereas the fields and attributes are not.
Though currently Groovy code, this is very likely to change to pure Java in a future release of Brooklyn so Groovy'isms should not be relied on.
Sub-classes should have a no-argument constructor. When brooklyn creates an entity, it will:
The legacy (pre 0.5) mechanism for creating entities is for others to call the constructor directly. This is now deprecated.
Field Summary | |
---|---|
protected static Logger |
LOG
|
static BasicNotificationSensor |
POLICY_ADDED
|
static BasicNotificationSensor |
POLICY_REMOVED
|
static BasicNotificationSensor |
SENSOR_ADDED
|
static BasicNotificationSensor |
SENSOR_REMOVED
|
protected SubscriptionTracker |
_subscriptionTracker
|
protected AttributeMap |
attributesInternal
The sensor-attribute values of this entity. |
protected EntityConfigMap |
configsInternal
The config values of this entity. |
protected EntityManagementSupport |
managementSupport
|
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 | |
---|---|
EntityCollectionReference |
children
|
java.util.Collection |
enrichers
|
EntityCollectionReference |
groups
|
java.util.Collection |
locations
|
java.util.Collection |
policies
|
java.util.Map |
presentationAttributes
|
boolean |
previouslyOwned
|
Constructor Summary | |
AbstractEntity()
|
|
AbstractEntity(java.util.Map flags)
@deprecated since 0.5; instead use no-arg constructor with EntityManager().createEntity(spec) |
|
AbstractEntity(Entity parent)
@deprecated since 0.5; instead use no-arg constructor with EntityManager().createEntity(spec) |
|
AbstractEntity(java.util.Map flags, Entity parent)
@deprecated since 0.5; instead use no-arg constructor with EntityManager().createEntity(spec) |
Method Summary | |
---|---|
Entity
|
addChild(Entity child)
Adds the given entity as a child of this parent and sets this entity as the parent of the child; returns argument passed in, for convenience. |
java.lang.Object
|
addChild(EntitySpec spec)
Creates an entity using the given spec, and adds it as a child of this entity. |
void
|
addEnricher(Enricher enricher)
|
void
|
addGroup(Group e)
Adds this as a member of the given group, registers with application if necessary |
void
|
addLocations(java.util.Collection newLocations)
|
Entity
|
addOwnedChild(Entity child)
|
void
|
addPolicy(Policy policy)
|
protected void
|
assertNotYetOwned()
|
void
|
clearOwner()
|
void
|
clearParent()
|
AbstractEntity
|
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) |
AbstractEntity
|
configure(ConfigKey key, java.lang.Object value)
Sets a config key value, and returns this Entity instance for use in fluent-API style coding. |
AbstractEntity
|
configure(ConfigKey key, java.lang.String value)
|
AbstractEntity
|
configure(HasConfigKey key, java.lang.Object value)
|
AbstractEntity
|
configure(HasConfigKey key, java.lang.String value)
|
protected EntityManagementSupport
|
createManagementSupport()
|
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)
|
boolean
|
equals(java.lang.Object o)
|
protected void
|
finalize()
|
Location
|
firstLocation()
|
java.util.Map
|
getAllAttributes()
|
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.util.Collection
|
getChildren()
|
EntityCollectionReference
|
getChildrenReference()
|
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)
|
EntityConfigMap
|
getConfigMap()
|
java.lang.String
|
getDisplayName()
|
Effector
|
getEffector(java.lang.String effectorName)
Convenience for finding named effector in getEffectors() java.util.Map. |
java.util.Collection
|
getEnrichers()
|
protected EntityManager
|
getEntityManager()
|
EntityType
|
getEntityType()
|
protected java.lang.String
|
getEntityTypeName()
Gets the entity type name, to be returned by getEntityType().getName(). |
ExecutionContext
|
getExecutionContext()
|
java.util.Collection
|
getGroups()
|
java.lang.String
|
getId()
|
java.util.Collection
|
getLocations()
|
ManagementContext
|
getManagementContext()
|
EntityManagementSupport
|
getManagementSupport()
|
EntityDynamicType
|
getMutableEntityType()
returns the dynamic type corresponding to the type of this entity instance |
java.util.Collection
|
getOwnedChildren()
|
EntityCollectionReference
|
getOwnedChildrenReference()
|
Entity
|
getOwner()
|
Entity
|
getParent()
|
java.util.Collection
|
getPolicies()
|
Entity
|
getProxy()
|
Entity
|
getProxyIfAvailable()
Returns the proxy, or if not available (because using legacy code) then returns the real entity. |
RebindSupport
|
getRebindSupport()
|
SubscriptionContext
|
getSubscriptionContext()
|
protected SubscriptionTracker
|
getSubscriptionTracker()
|
boolean
|
hasEverBeenManaged()
FIXME Temporary workaround for use-case: - the load balancing policy test calls app.managementContext.unmanage(itemToStop) - concurrently, the policy calls an effector on that item: item.move() - The code in AbstractManagementContext.invokeEffectorMethodSync calls manageIfNecessary. |
int
|
hashCode()
|
void
|
init()
Called by framework (in new-style entities) after configuring, setting parent, etc, but before a reference to this entity is shared with other entities. |
void
|
invalidateReferences()
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). |
protected boolean
|
isLegacyConstruction()
|
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
|
onManagementStarted()
Invoked by EntityManagementSupport when this entity is fully managed and visible to other entities through the management context. |
void
|
onManagementStarting()
Invoked by EntityManagementSupport when this entity is becoming managed (i.e. it has a working management context, but before the entity is visible to other entities). |
void
|
refreshInheritedConfig()
|
void
|
refreshInheritedConfigOfChildren()
|
boolean
|
removeAllEnrichers()
|
boolean
|
removeAllPolicies()
|
void
|
removeAttribute(AttributeSensor attribute)
|
boolean
|
removeChild(Entity child)
|
boolean
|
removeEnricher(Enricher enricher)
|
void
|
removeLocations(java.util.Collection newLocations)
|
boolean
|
removeOwnedChild(Entity child)
|
boolean
|
removePolicy(Policy policy)
|
protected void
|
setApplication(Application app)
@deprecated since 0.4.0 should not be needed / leaked outwith brooklyn internals / mgmt support? |
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 |
java.lang.Object
|
setAttributeWithoutPublishing(AttributeSensor attribute, java.lang.Object val)
|
void
|
setBeingManaged()
@deprecated since 0.4.0 now handled by EntityMangementSupport |
java.lang.Object
|
setConfig(ConfigKey key, java.lang.Object val)
|
java.lang.Object
|
setConfig(ConfigKey key, Task val)
|
java.lang.Object
|
setConfig(ConfigKey key, DeferredSupplier val)
|
java.lang.Object
|
setConfig(HasConfigKey key, java.lang.Object val)
|
java.lang.Object
|
setConfig(HasConfigKey key, Task val)
|
java.lang.Object
|
setConfig(HasConfigKey key, DeferredSupplier val)
|
java.lang.Object
|
setConfigEvenIfOwned(ConfigKey key, java.lang.Object val)
|
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)
|
void
|
setDisplayName(java.lang.String newDisplayName)
|
void
|
setManagementContext(ManagementContextInternal managementContext)
|
AbstractEntity
|
setOwner(Entity entity)
|
AbstractEntity
|
setParent(Entity entity)
Adds this as a child of the given entity; registers with application if necessary. |
void
|
setProxy(Entity proxy)
|
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 ToStringHelper
|
toStringHelper()
Override this to add to the toString(), e.g. |
boolean
|
unsubscribe(Entity producer)
Unsubscribes the given producer. |
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 |
---|
protected static final Logger LOG
public static BasicNotificationSensor POLICY_ADDED
public static BasicNotificationSensor POLICY_REMOVED
public static BasicNotificationSensor SENSOR_ADDED
public static BasicNotificationSensor SENSOR_REMOVED
protected SubscriptionTracker _subscriptionTracker
protected final AttributeMap attributesInternal
protected final EntityConfigMap configsInternal
protected EntityManagementSupport managementSupport
protected final java.util.Map tempWorkings
Property Detail |
---|
final EntityCollectionReference children
java.util.Collection enrichers
final EntityCollectionReference groups
java.util.Collection locations
java.util.Collection policies
java.util.Map presentationAttributes
boolean previouslyOwned
Constructor Detail |
---|
AbstractEntity()
@Deprecated AbstractEntity(java.util.Map flags)
@Deprecated AbstractEntity(Entity parent)
@Deprecated AbstractEntity(java.util.Map flags, Entity parent)
Method Detail |
---|
@Override Entity addChild(Entity child)
@Override java.lang.Object addChild(EntitySpec spec)
@Override void addEnricher(Enricher enricher)
@Override void addGroup(Group e)
@Override void addLocations(java.util.Collection newLocations)
@Override @Deprecated // see addChild(Entity) Entity addOwnedChild(Entity child)
@Override void addPolicy(Policy policy)
protected void assertNotYetOwned()
@Override @Deprecated // see clearParent void clearOwner()
@Override void clearParent()
AbstractEntity configure(java.util.Map flags = [:])
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
AbstractEntity configure(ConfigKey key, java.lang.Object value)
AbstractEntity configure(ConfigKey key, java.lang.String value)
AbstractEntity configure(HasConfigKey key, java.lang.Object value)
AbstractEntity configure(HasConfigKey key, java.lang.String value)
protected EntityManagementSupport createManagementSupport()
@Override void destroy()
@Override void emit(Sensor sensor, java.lang.Object val)
@Override void emitInternal(Sensor sensor, java.lang.Object val)
boolean equals(java.lang.Object o)
protected void finalize()
Location firstLocation()
java.util.Map getAllAttributes()
java.util.Map getAllConfig()
@Override Application getApplication()
@Override java.lang.String getApplicationId()
@Override java.lang.Object getAttribute(AttributeSensor attribute)
java.lang.Object getAttributeByNameParts(java.util.List nameParts)
@Override java.util.Collection getChildren()
EntityCollectionReference getChildrenReference()
@Override java.lang.Object getConfig(ConfigKey key)
@Override java.lang.Object getConfig(HasConfigKey key)
@Override java.lang.Object getConfig(HasConfigKey key, java.lang.Object defaultValue)
@Override java.lang.Object getConfig(ConfigKey key, java.lang.Object defaultValue)
EntityConfigMap getConfigMap()
java.lang.String getDisplayName()
Effector getEffector(java.lang.String effectorName)
@Override java.util.Collection getEnrichers()
protected EntityManager getEntityManager()
@Override EntityType getEntityType()
protected java.lang.String getEntityTypeName()
ExecutionContext getExecutionContext()
@Override java.util.Collection getGroups()
java.lang.String getId()
@Override java.util.Collection getLocations()
@Override ManagementContext getManagementContext()
EntityManagementSupport getManagementSupport()
EntityDynamicType getMutableEntityType()
@Override @Deprecated java.util.Collection getOwnedChildren()
@Deprecated EntityCollectionReference getOwnedChildrenReference()
@Override @Deprecated Entity getOwner()
@Override Entity getParent()
@Override java.util.Collection getPolicies()
Entity getProxy()
@Beta Entity getProxyIfAvailable()
@Override RebindSupport getRebindSupport()
SubscriptionContext getSubscriptionContext()
protected SubscriptionTracker getSubscriptionTracker()
boolean hasEverBeenManaged()
int hashCode()
void init()
if (isLegacyConstruction()) { init(); }
void invalidateReferences()
Task invoke(java.util.Map parameters = [:], Effector eff)
Task invoke(Effector eff, java.util.Map parameters)
Task invokeFromJava(java.util.Map parameters = [:], Effector eff)
java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
protected boolean isLegacyConstruction()
void onManagementBecomingMaster()
void onManagementNoLongerMaster()
void onManagementStarted()
void onManagementStarting()
void refreshInheritedConfig()
void refreshInheritedConfigOfChildren()
@Override boolean removeAllEnrichers()
@Override boolean removeAllPolicies()
@Override void removeAttribute(AttributeSensor attribute)
@Override boolean removeChild(Entity child)
@Override boolean removeEnricher(Enricher enricher)
@Override void removeLocations(java.util.Collection newLocations)
@Override @Deprecated // see removeChild(Entity) boolean removeOwnedChild(Entity child)
@Override boolean removePolicy(Policy policy)
protected void setApplication(Application app)
@Override java.lang.Object setAttribute(AttributeSensor attribute, java.lang.Object val)
java.lang.Object setAttribute(AttributeSensorAndConfigKey configuredSensor)
returns old value
@Override java.lang.Object setAttributeWithoutPublishing(AttributeSensor attribute, java.lang.Object val)
void setBeingManaged()
@Override java.lang.Object setConfig(ConfigKey key, java.lang.Object val)
java.lang.Object setConfig(ConfigKey key, Task val)
java.lang.Object setConfig(ConfigKey key, DeferredSupplier val)
@Override java.lang.Object setConfig(HasConfigKey key, java.lang.Object val)
java.lang.Object setConfig(HasConfigKey key, Task val)
java.lang.Object setConfig(HasConfigKey key, DeferredSupplier val)
java.lang.Object setConfigEvenIfOwned(ConfigKey key, java.lang.Object val)
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)
void setDisplayName(java.lang.String newDisplayName)
void setManagementContext(ManagementContextInternal managementContext)
@Override @Deprecated // see setParent(Entity) AbstractEntity setOwner(Entity entity)
@Override AbstractEntity setParent(Entity entity)
void setProxy(Entity proxy)
SubscriptionHandle subscribe(Entity producer, Sensor sensor, SensorEventListener listener)
SubscriptionHandle subscribeToChildren(Entity parent, Sensor sensor, SensorEventListener listener)
SubscriptionHandle subscribeToMembers(Group group, Sensor sensor, SensorEventListener listener)
@Override java.lang.String toString()
@Deprecated java.util.Collection toStringFieldsToInclude()
protected ToStringHelper toStringHelper()
@Override boolean unsubscribe(Entity producer)
@Override boolean unsubscribe(Entity producer, SubscriptionHandle handle)
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.