|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrooklyn.entity.basic.AbstractEntity
public abstract class AbstractEntity
Default Entity implementation, which should be extended whenever implementing an entity.
Provides several common fields (displayName, 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 | |
---|---|
static BasicNotificationSensor |
EFFECTOR_ADDED
|
static BasicNotificationSensor |
EFFECTOR_CHANGED
|
static BasicNotificationSensor |
EFFECTOR_REMOVED
|
protected static Logger |
LOG
@deprecated since 0.6; will be made private in subsequent release; instead declare more appropriate logger |
static BasicNotificationSensor |
POLICY_ADDED
|
static BasicNotificationSensor |
POLICY_REMOVED
|
static BasicNotificationSensor |
SENSOR_ADDED
|
static BasicNotificationSensor |
SENSOR_REMOVED
|
protected SubscriptionTracker |
_subscriptionTracker
|
protected EntityManagementSupport |
managementSupport
|
protected java.util.Map |
tempWorkings
|
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)
|
Method Summary | |
---|---|
java.lang.Object
|
addChild(java.lang.Object child)
|
java.lang.Object
|
addChild(EntitySpec spec)
Adds this as a member of the given group, registers with application if necessary |
void
|
addEnricher(Enricher enricher)
Invoke an Effector directly. |
void
|
addGroup(Group e)
Returns the application, looking it up if not yet known (registering if necessary) |
void
|
addLocations(java.util.Collection newLocations)
|
void
|
addPolicy(Policy policy)
|
void
|
clearLocations()
|
void
|
clearParent()
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. |
AbstractEntity
|
configure()
|
AbstractEntity
|
configure(java.util.Map flags)
|
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)
|
void
|
destroy()
|
void
|
emit(Sensor sensor, java.lang.Object val)
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
|
emitInternal(Sensor sensor, java.lang.Object val)
Invoked by EntityManagementSupport when this entity is fully managed and visible to other entities through the management context. |
boolean
|
equals(java.lang.Object o)
|
protected void
|
finalize()
|
Location
|
firstLocation()
|
java.util.Map
|
getAllAttributes()
|
java.util.Map
|
getAllConfig()
|
Application
|
getApplication()
|
java.lang.String
|
getApplicationId()
|
java.lang.Object
|
getAttribute(AttributeSensor attribute)
|
java.lang.Object
|
getAttributeByNameParts(java.util.List nameParts)
|
java.util.Collection
|
getChildren()
@deprecated since 0.4.0 should not be needed / leaked outwith brooklyn internals / mgmt support? |
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()
|
long
|
getCreationTime()
|
java.lang.String
|
getDisplayName()
|
Effector
|
getEffector(java.lang.String effectorName)
|
java.util.Collection
|
getEnrichers()
Convenience for finding named effector in EntityType#getEffectors()#getEffectors() java.util.Map. |
protected EntityManager
|
getEntityManager()
|
EntityType
|
getEntityType()
|
protected java.lang.String
|
getEntityTypeName()
|
ExecutionContext
|
getExecutionContext()
|
java.util.Collection
|
getGroups()
|
java.lang.String
|
getIconUrl()
|
java.lang.String
|
getId()
|
java.util.Collection
|
getLocations()
|
ManagementContext
|
getManagementContext()
|
EntityManagementSupport
|
getManagementSupport()
|
EntityDynamicType
|
getMutableEntityType()
|
Entity
|
getParent()
|
java.util.Collection
|
getPolicies()
|
Entity
|
getProxy()
|
Entity
|
getProxyIfAvailable()
|
RebindSupport
|
getRebindSupport()
|
SubscriptionContext
|
getSubscriptionContext()
|
protected SubscriptionTracker
|
getSubscriptionTracker()
|
int
|
hashCode()
|
void
|
init()
Adds this as a child of the given entity; registers with application if necessary. |
void
|
invalidateReferences()
|
Task
|
invoke(Effector eff)
|
Task
|
invoke(java.util.Map parameters, Effector eff)
|
Task
|
invoke(Effector eff, java.util.Map parameters)
|
protected boolean
|
isLegacyConstruction()
|
void
|
onManagementBecomingMaster()
|
void
|
onManagementNoLongerMaster()
|
void
|
onManagementStarted()
|
void
|
onManagementStarting()
For use by management plane, to invalidate all fields (e.g. when an entity is changing to being proxied) |
void
|
onManagementStopped()
|
void
|
refreshInheritedConfig()
|
boolean
|
removeAllEnrichers()
|
boolean
|
removeAllPolicies()
|
void
|
removeAttribute(AttributeSensor attribute)
|
boolean
|
removeChild(Entity child)
|
boolean
|
removeEnricher(Enricher enricher)
|
void
|
removeLocations(java.util.Collection removedLocations)
Should be invoked at end-of-life to clean up the item. |
boolean
|
removePolicy(Policy policy)
|
protected void
|
setApplication(Application app)
|
java.lang.Object
|
setAttribute(AttributeSensor attribute, java.lang.Object val)
|
java.lang.Object
|
setAttribute(AttributeSensorAndConfigKey configuredSensor)
|
java.lang.Object
|
setAttributeWithoutPublishing(AttributeSensor attribute, java.lang.Object val)
|
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)
@see EntityLocal#subscribe |
void
|
setDisplayName(java.lang.String newDisplayName)
|
void
|
setManagementContext(ManagementContextInternal managementContext)
|
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)
Default String representation is simplified name of class, together with selected fields. |
java.util.Map
|
toMetadataRecord()
|
java.lang.String
|
toString()
|
protected ToStringHelper
|
toStringHelper()
|
boolean
|
unsubscribe(Entity producer)
Override this to add to the toString(), e.g. |
boolean
|
unsubscribe(Entity producer, SubscriptionHandle handle)
|
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 |
---|
public static final BasicNotificationSensor EFFECTOR_ADDED
public static final BasicNotificationSensor EFFECTOR_CHANGED
public static final BasicNotificationSensor EFFECTOR_REMOVED
@Deprecated protected static final Logger LOG
public static final BasicNotificationSensor POLICY_ADDED
public static final BasicNotificationSensor POLICY_REMOVED
public static final BasicNotificationSensor SENSOR_ADDED
public static final BasicNotificationSensor SENSOR_REMOVED
protected SubscriptionTracker _subscriptionTracker
protected final EntityManagementSupport managementSupport
} protected final java.util.Map tempWorkings
Constructor Detail |
---|
public AbstractEntity()
public AbstractEntity(Entity parent) { public AbstractEntity(java.util.Map flags)
@Deprecated public AbstractEntity(Entity parent)
} public AbstractEntity(java.util.Map flags, Entity parent)
Method Detail |
---|
synchronized (children) { public java.lang.Object addChild(java.lang.Object child)
public Entity getParent() { public java.lang.Object addChild(EntitySpec spec)
publicTask invoke(Effector eff) { public void addEnricher(Enricher enricher)
setApplication(app); public void addGroup(Group e)
} public void addLocations(java.util.Collection newLocations)
return enrichers.remove(enricher); public void addPolicy(Policy policy)
} public void clearLocations()
*/ public void clearParent()
public AbstractEntity configure()
if (suppliedParent != null) { public AbstractEntity configure(java.util.Map flags)
public AbstractEntity configure(ConfigKey key, java.lang.Object value)
public AbstractEntity configure(ConfigKey key, java.lang.String value)
public AbstractEntity configure(HasConfigKey key, java.lang.Object value)
public AbstractEntity configure(HasConfigKey key, java.lang.String value)
entityType.removeSensor(attribute); public void destroy()
entityType.setName(getEntityTypeName()); public void emit(Sensor sensor, java.lang.Object val)
public void emitInternal(Sensor sensor, java.lang.Object val)
return id; public boolean equals(java.lang.Object o)
protected void finalize()
public Location firstLocation()
*/ public java.util.Map getAllAttributes()
public java.util.Map getAllConfig()
return getManagementSupport().getManagementContext(); public Application getApplication()
public void addLocations(Collection extends Location> newLocations) { public java.lang.String getApplicationId()
* if the attribtue sensor is not-set or null public java.lang.Object getAttribute(AttributeSensor attribute)
public java.lang.Object getAttributeByNameParts(java.util.List nameParts)
} public java.util.Collection getChildren()
} public java.lang.Object getConfig(ConfigKey key)
public java.lang.Object getConfig(HasConfigKey key)
public java.lang.Object getConfig(HasConfigKey key, java.lang.Object defaultValue)
return setConfig(key.getConfigKey(), val); public java.lang.Object getConfig(ConfigKey key, java.lang.Object defaultValue)
*/ public EntityConfigMap getConfigMap()
* To be called by brooklyn internals only. public long getCreationTime()
Class> typeClazz = getManagementContext().getEntityManager().getEntityTypeRegistry().getEntityTypeOf(getClass()); public java.lang.String getDisplayName()
public Effector getEffector(java.lang.String effectorName)
public Effector> getEffector(String effectorName) { public java.util.Collection getEnrichers()
protected EntityManager getEntityManager()
} public EntityType getEntityType()
protected java.lang.String getEntityTypeName()
} public ExecutionContext getExecutionContext()
@Override public java.util.Collection getGroups()
String typeName = getClass().getCanonicalName(); public java.lang.String getIconUrl()
return selfProxy; public java.lang.String getId()
public java.util.Collection getLocations()
locations.set(ImmutableList.builder().addAll(oldLocations).addAll(truelyNewLocations).build()); public ManagementContext getManagementContext()
public EntityManagementSupport getManagementSupport()
public void removeLocations(Collection extends Location> removedLocations) { public EntityDynamicType getMutableEntityType()
/** @deprecated since 0.4.0 should not be needed / leaked outwith brooklyn internals / mgmt support? */ public Entity getParent()
} public java.util.Collection getPolicies()
public Entity getProxy()
* public Entity getProxyIfAvailable()
public RebindSupport getRebindSupport()
getManagementSupport().getEntityChangeListener().onPoliciesChanged(); public SubscriptionContext getSubscriptionContext()
protected SubscriptionTracker getSubscriptionTracker()
return _legacyConstruction; public int hashCode()
public void init()
public void invalidateReferences()
public Task invoke(Effector eff)
public Task invoke(java.util.Map parameters, Effector eff)
} public Task invoke(Effector eff, java.util.Map parameters)
protected boolean isLegacyConstruction()
public void onManagementBecomingMaster()
public void onManagementNoLongerMaster()
public void onManagementStarted()
public void onManagementStarting()
public void onManagementStopped()
public void refreshInheritedConfig()
*/ public boolean removeAllEnrichers()
LOG.warn("Strongly discouraged use of emit with sensor event as value "+sensor+" "+val+"; value should be unpacked!", public boolean removeAllPolicies()
if (!inConstruction && getManagementSupport().isDeployed()) { public void removeAttribute(AttributeSensor attribute)
@Override public boolean removeChild(Entity child)
} public boolean removeEnricher(Enricher enricher)
@Override public void removeLocations(java.util.Collection removedLocations)
return changed; public boolean removePolicy(Policy policy)
protected void setApplication(Application app)
return null; public java.lang.Object setAttribute(AttributeSensor attribute, java.lang.Object val)
public java.lang.Object setAttribute(AttributeSensorAndConfigKey configuredSensor)
@Override public java.lang.Object setAttributeWithoutPublishing(AttributeSensor attribute, java.lang.Object val)
configsInternal.setInheritedConfig(((EntityInternal)getParent()).getAllConfig()); public java.lang.Object setConfig(ConfigKey key, java.lang.Object val)
refreshInheritedConfigOfChildren(); public java.lang.Object setConfig(ConfigKey key, Task val)
public java.lang.Object setConfig(ConfigKey key, DeferredSupplier val)
@Override public java.lang.Object setConfig(HasConfigKey key, java.lang.Object val)
@Override public java.lang.Object setConfig(HasConfigKey key, Task val)
public java.lang.Object setConfig(HasConfigKey key, DeferredSupplier val)
public java.lang.Object setConfigEvenIfOwned(ConfigKey key, java.lang.Object val)
public 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)
} public void setDisplayName(java.lang.String newDisplayName)
public void setManagementContext(ManagementContextInternal managementContext)
entity.addChild(getProxyIfAvailable()); public AbstractEntity setParent(Entity entity)
public void setProxy(Entity proxy)
} public SubscriptionHandle subscribe(Entity producer, Sensor sensor, SensorEventListener listener)
public SubscriptionHandle subscribeToChildren(Entity parent, Sensor sensor, SensorEventListener listener)
public SubscriptionHandle subscribeToMembers(Group group, Sensor sensor, SensorEventListener listener)
displayNameAutoGenerated = false; public java.util.Map toMetadataRecord()
boolean changed = false; public java.lang.String toString()
protected ToStringHelper toStringHelper()
} public boolean unsubscribe(Entity producer)
@Override public boolean unsubscribe(Entity producer, SubscriptionHandle handle)
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.