public abstract class BaseAgent extends java.lang.Object implements ObservableAgent
Agent
. It provides basic functionality required in each Agent
. Implements
the ObservableAgent
interface to make sure the instance van send AgentEvent
s to AgentObserver
s.Agent.Status
Modifier and Type | Field and Description |
---|---|
protected org.flexiblepower.context.FlexiblePowerContext |
context |
protected org.slf4j.Logger |
LOGGER |
Constructor and Description |
---|
BaseAgent() |
Modifier and Type | Method and Description |
---|---|
void |
addObserver(AgentObserver observer)
Used to add an
AgentObserver to the list of observers of this instance. |
protected java.util.Date |
now()
Returns the current time in a
Date object. |
protected void |
publishEvent(AgentEvent event)
Publish an
AgentEvent to the attached Observer services. |
void |
removeObserver(AgentObserver observer)
Used to remove an
AgentObserver from the list of observers of this instance. |
void |
setContext(org.flexiblepower.context.FlexiblePowerContext context)
Give the agent a reference to a
FlexiblePowerContext . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAgentId, getStatus
protected final org.slf4j.Logger LOGGER
protected volatile org.flexiblepower.context.FlexiblePowerContext context
public void setContext(org.flexiblepower.context.FlexiblePowerContext context)
Agent
FlexiblePowerContext
. This should be done by the runtime bundle after the
component is activated.setContext
in interface Agent
context
- reference to the FlexiblePowerContext
Agent.setContext(org.flexiblepower.context.FlexiblePowerContext)
protected java.util.Date now()
Date
object.Date
object, representing the current date and timepublic void addObserver(AgentObserver observer)
AgentObserver
to the list of observers of this instance.addObserver
in interface ObservableAgent
observer
- the new AgentObserver
.public void removeObserver(AgentObserver observer)
AgentObserver
from the list of observers of this instance.removeObserver
in interface ObservableAgent
observer
- the AgentObserver
that will be removed.protected final void publishEvent(AgentEvent event)
AgentEvent
to the attached Observer
services.event
- The event to publish.