public abstract class MicroAgent extends Object implements IMicroAgent, IInternalAccess
Modifier and Type | Class and Description |
---|---|
static class |
MicroAgent.ExecuteWaitForStep
Step to execute a wait for entry.
|
Constructor and Description |
---|
MicroAgent() |
Modifier and Type | Method and Description |
---|---|
IFuture |
addComponentListener(IComponentListener listener)
Add an component listener.
|
void |
addMessageHandler(IMessageHandler handler)
Add a message handler.
|
IFuture |
addService(String name,
Class type,
Object service)
Add a service to the platform.
|
IFuture |
addService(String name,
Class type,
Object service,
String proxytype)
Add a service to the platform.
|
IFuture |
agentCreated()
Called once after agent creation.
|
IFuture |
agentKilled()
Called just before the agent is removed from the platform.
|
IFuture |
createComponentIdentifier(String name)
Create component identifier.
|
IFuture |
createComponentIdentifier(String name,
boolean local)
Create component identifier.
|
IFuture |
createComponentIdentifier(String name,
boolean local,
String[] addresses)
Create component identifier.
|
IFuture |
createReply(Map msg,
MessageType mt)
Create a reply to this message event.
|
<T> IIntermediateResultListener<T> |
createResultListener(IIntermediateResultListener<T> listener)
Create a result listener that is executed as an agent step.
|
<T> IResultListener<T> |
createResultListener(IResultListener<T> listener)
Create a result listener that is executed as an agent step.
|
IServiceContainer |
createServiceContainer(Map args)
May be overriden to provide a custom service container implementations.
|
void |
executeBody()
Execute the functional body of the agent.
|
IComponentAdapter |
getAgentAdapter()
Get the agent adapter.
|
String |
getAgentName()
Get the agent name.
|
Object |
getArgument(String name)
Get an argument.
|
Map |
getArguments()
Get the arguments.
|
IFuture |
getChildren()
Get the children (if any).
|
IComponentAdapter |
getComponentAdapter()
Get the agent adapter.
|
IComponentDescription |
getComponentDescription()
Get the component description.
|
IComponentIdentifier |
getComponentIdentifier()
Get the agent identifier.
|
String |
getConfiguration()
Get the configuration.
|
IExternalAccess |
getExternalAccess()
Get the external access for this agent.
|
IValueFetcher |
getFetcher()
Get the fetcher.
|
Logger |
getLogger()
Get the logger.
|
IModelInfo |
getModel()
Get the model of the component.
|
IExternalAccess |
getParent()
Get the parent component.
|
Object |
getProperty(String name)
Get a property.
|
Object |
getRawService(Class type)
Get a raw reference to a provided service implementation.
|
Object[] |
getRawServices(Class type)
Get a raw reference to a provided service implementation.
|
IFuture |
getRequiredService(String name)
Get a required service of a given name.
|
IIntermediateFuture |
getRequiredServices(String name)
Get a required services of a given name.
|
Map |
getResults()
Get the component results.
|
IServiceContainer |
getServiceContainer()
Get the service container.
|
IServiceProvider |
getServiceProvider()
Get the service provider.
|
IFuture |
getTime()
Get the current time.
|
void |
init(MicroAgentInterpreter interpreter)
Init the micro agent with the interpreter.
|
boolean |
isAtBreakpoint(String[] breakpoints)
Test if the agent's execution is currently at one of the
given breakpoints.
|
IFuture |
killAgent()
Kill the agent.
|
IFuture |
killComponent()
Kill the component.
|
void |
messageArrived(Map msg,
MessageType mt)
Called, whenever a message is received.
|
IFuture |
removeComponentListener(IComponentListener listener)
Remove a component listener.
|
void |
removeMessageHandler(IMessageHandler handler)
Remove a message handler.
|
IFuture |
removeService(IServiceIdentifier sid)
Removes a service from the platform (shutdowns also the service).
|
<T> IFuture<T> |
scheduleStep(IComponentStep<T> step)
Schedule a step of the agent.
|
IFuture |
sendMessage(Map me,
MessageType mt)
Send a message.
|
IFuture |
sendMessage(Map me,
MessageType mt,
byte[] codecids)
Send a message.
|
IFuture |
sendMessageAndWait(Map me,
MessageType mt,
IMessageHandler handler)
Send a message and wait for a reply.
|
void |
setResultValue(String name,
Object value)
Set a result value.
|
IFuture<jadex.micro.MicroAgent.TimerWrapper> |
waitFor(long time,
IComponentStep<Void> run)
Wait for an specified amount of time.
|
IFuture<jadex.micro.MicroAgent.TimerWrapper> |
waitForTick(IComponentStep<Void> run)
Wait for the next tick.
|
public void init(MicroAgentInterpreter interpreter)
interpreter
- The interpreter.public IFuture agentCreated()
agentCreated
in interface IMicroAgent
public void executeBody()
executeBody
in interface IMicroAgent
public void messageArrived(Map msg, MessageType mt)
messageArrived
in interface IMicroAgent
msg
- The message.mt
- The message type.public IFuture agentKilled()
agentKilled
in interface IMicroAgent
public Object getProperty(String name)
name
- The name of the property.public IServiceProvider getServiceProvider()
public IServiceContainer getServiceContainer()
getServiceContainer
in interface IInternalAccess
public boolean isAtBreakpoint(String[] breakpoints)
breakpoints
- An array of breakpoints.public IExternalAccess getExternalAccess()
getExternalAccess
in interface IInternalAccess
public IExternalAccess getParent()
getParent
in interface IInternalAccess
public IComponentAdapter getAgentAdapter()
public IComponentAdapter getComponentAdapter()
public IComponentDescription getComponentDescription()
public Map getArguments()
getArguments
in interface IInternalAccess
public Map getResults()
getResults
in interface IInternalAccess
public void setResultValue(String name, Object value)
setResultValue
in interface IInternalAccess
name
- The result name.value
- The result value.public Object getArgument(String name)
name
- The argument name.public String getConfiguration()
getConfiguration
in interface IInternalAccess
public Object getRawService(Class type)
public Object[] getRawServices(Class type)
public <T> IResultListener<T> createResultListener(IResultListener<T> listener)
createResultListener
in interface IInternalAccess
listener
- The listener to be executed as an agent step.public <T> IIntermediateResultListener<T> createResultListener(IIntermediateResultListener<T> listener)
createResultListener
in interface IInternalAccess
listener
- The listener to be executed as an agent step.public IFuture getTime()
public IFuture<jadex.micro.MicroAgent.TimerWrapper> waitFor(long time, IComponentStep<Void> run)
time
- The time.run
- The runnable.public IFuture<jadex.micro.MicroAgent.TimerWrapper> waitForTick(IComponentStep<Void> run)
time
- The time.public Logger getLogger()
getLogger
in interface IInternalAccess
public IFuture killAgent()
public IFuture sendMessage(Map me, MessageType mt)
me
- The message content (name value pairs).mt
- The message type describing the content.public IFuture sendMessage(Map me, MessageType mt, byte[] codecids)
me
- The message content (name value pairs).mt
- The message type describing the content.public IFuture sendMessageAndWait(Map me, MessageType mt, IMessageHandler handler)
me
- The message content (name value pairs).mt
- The message type describing the content.public void addMessageHandler(IMessageHandler handler)
The
- handler.public void removeMessageHandler(IMessageHandler handler)
handler
- The handler.public IFuture createComponentIdentifier(String name)
name
- The name.local
- True for local name.addresses
- The addresses.public IFuture createComponentIdentifier(String name, boolean local)
name
- The name.local
- True for local name.addresses
- The addresses.public IFuture createComponentIdentifier(String name, boolean local, String[] addresses)
name
- The name.local
- True for local name.addresses
- The addresses.public IFuture createReply(Map msg, MessageType mt)
msgeventtype
- The message event type.public String getAgentName()
public IComponentIdentifier getComponentIdentifier()
getComponentIdentifier
in interface IInternalAccess
public <T> IFuture<T> scheduleStep(IComponentStep<T> step)
step
- Code to be executed as a step of the agent.public IFuture addService(String name, Class type, Object service, String proxytype)
type
- The public service interface.service
- The service.type
- The proxy type (@see{BasicServiceInvocationHandler}).public IFuture addService(String name, Class type, Object service)
type
- The public service interface.service
- The service.public IFuture removeService(IServiceIdentifier sid)
service
- The service.public IModelInfo getModel()
getModel
in interface IInternalAccess
public IFuture getChildren()
getChildren
in interface IInternalAccess
public IFuture killComponent()
killComponent
in interface IInternalAccess
public IFuture addComponentListener(IComponentListener listener)
addComponentListener
in interface IInternalAccess
listener
- The listener.public IFuture removeComponentListener(IComponentListener listener)
removeComponentListener
in interface IInternalAccess
listener
- The listener.public IFuture getRequiredService(String name)
name
- The service name.public IIntermediateFuture getRequiredServices(String name)
name
- The services name.public IServiceContainer createServiceContainer(Map args)
public IValueFetcher getFetcher()
getFetcher
in interface IInternalAccess
Copyright © 2012. All Rights Reserved.