public 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<Void> |
addComponentListener(IComponentListener listener)
Add an component listener.
|
void |
addMessageHandler(IMessageHandler handler)
Add a message handler.
|
IFuture<Void> |
addService(String name,
Class<?> type,
Object service)
Add a service to the platform.
|
IFuture<Void> |
addService(String name,
Class<?> type,
Object service,
String proxytype)
Add a service to the platform.
|
IFuture<Void> |
agentCreated()
Called once after agent creation.
|
IFuture<Void> |
agentKilled()
Called just before the agent is removed from the platform.
|
Map<String,Object> |
createReply(Map<String,Object> 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<String,Object> args)
May be overriden to provide a custom service container implementations.
|
IFuture<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<String,Object> |
getArguments()
Get the arguments.
|
IFuture<Collection<IExternalAccess>> |
getChildrenAccesses()
Get the children (if any).
|
IFuture<IComponentIdentifier[]> |
getChildrenIdentifiers()
Get the children (if any).
|
ClassLoader |
getClassLoader()
Get the class loader of the component.
|
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.
|
MicroAgentInterpreter |
getInterpreter()
Get the interpreter.
|
Logger |
getLogger()
Get the logger.
|
IModelInfo |
getModel()
Get the model of the component.
|
IExternalAccess |
getParentAccess()
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 |
getRawService(String name)
Get a raw reference to a provided service implementation.
|
Object[] |
getRawServices(Class<?> type)
Get a raw reference to a provided service implementation.
|
<T> IFuture<T> |
getRequiredService(String name)
Get a required service of a given name.
|
<T> IIntermediateFuture<T> |
getRequiredServices(String name)
Get a required services of a given name.
|
Map<String,Object> |
getResults()
Get the component results.
|
IServiceContainer |
getServiceContainer()
Get the service container.
|
IServiceProvider |
getServiceProvider()
Get the service provider.
|
IFuture<Long> |
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.
|
boolean |
isComponentThread()
Test if current thread is the component thread.
|
IFuture<Map<String,Object>> |
killAgent()
Kill the agent.
|
IFuture<Map<String,Object>> |
killComponent()
Kill the component.
|
void |
messageArrived(Map<String,Object> msg,
MessageType mt)
Called, whenever a message is received.
|
IFuture<Void> |
removeComponentListener(IComponentListener listener)
Remove a component listener.
|
void |
removeMessageHandler(IMessageHandler handler)
Remove a message handler.
|
IFuture<Void> |
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<Void> |
sendMessage(Map<String,Object> me,
MessageType mt)
Send a message.
|
IFuture<Void> |
sendMessage(Map<String,Object> me,
MessageType mt,
byte[] codecids)
Send a message.
|
IFuture<Void> |
sendMessageAndWait(Map<String,Object> me,
MessageType mt,
IMessageHandler handler)
Send a message and wait for a reply.
|
void |
setResultValue(String name,
Object value)
Set a result value.
|
void |
streamArrived(IConnection con)
Called, whenever a stream is received.
|
IFuture<MicroAgent.TimerWrapper> |
waitFor(long time,
IComponentStep<Void> step)
Wait for an specified amount of time.
|
<T> IFuture<T> |
waitForDelay(long delay,
IComponentStep<T> step)
Wait for some time and execute a component step afterwards.
|
IFuture<MicroAgent.TimerWrapper> |
waitForTick(IComponentStep<Void> run)
Wait for the next tick.
|
public void init(MicroAgentInterpreter interpreter)
interpreter - The interpreter.public IFuture<Void> agentCreated()
agentCreated in interface IMicroAgentpublic IFuture<Void> executeBody()
executeBody in interface IMicroAgentpublic void messageArrived(Map<String,Object> msg, MessageType mt)
messageArrived in interface IMicroAgentmsg - The message.mt - The message type.public void streamArrived(IConnection con)
con - The stream.public IFuture<Void> agentKilled()
agentKilled in interface IMicroAgentpublic Object getProperty(String name)
name - The name of the property.public IServiceProvider getServiceProvider()
public IServiceContainer getServiceContainer()
getServiceContainer in interface IInternalAccesspublic boolean isAtBreakpoint(String[] breakpoints)
breakpoints - An array of breakpoints.public IExternalAccess getExternalAccess()
getExternalAccess in interface IInternalAccesspublic IExternalAccess getParentAccess()
getParentAccess in interface IInternalAccesspublic IComponentAdapter getAgentAdapter()
public IComponentAdapter getComponentAdapter()
public IComponentDescription getComponentDescription()
getComponentDescription in interface IInternalAccesspublic Map<String,Object> getArguments()
getArguments in interface IInternalAccesspublic Map<String,Object> getResults()
getResults in interface IInternalAccesspublic void setResultValue(String name, Object value)
setResultValue in interface IInternalAccessname - The result name.value - The result value.public Object getArgument(String name)
name - The argument name.public String getConfiguration()
getConfiguration in interface IInternalAccesspublic Object getRawService(String name)
public Object getRawService(Class<?> type)
public Object[] getRawServices(Class<?> type)
public <T> IResultListener<T> createResultListener(IResultListener<T> listener)
createResultListener in interface IInternalAccesslistener - The listener to be executed as an agent step.public <T> IIntermediateResultListener<T> createResultListener(IIntermediateResultListener<T> listener)
createResultListener in interface IInternalAccesslistener - The listener to be executed as an agent step.public IFuture<MicroAgent.TimerWrapper> waitFor(long time, IComponentStep<Void> step)
time - The time.step - The runnable.public IFuture<MicroAgent.TimerWrapper> waitForTick(IComponentStep<Void> run)
time - The time.public Logger getLogger()
getLogger in interface IInternalAccesspublic IFuture<Void> sendMessage(Map<String,Object> me, MessageType mt)
me - The message content (name value pairs).mt - The message type describing the content.public IFuture<Void> sendMessage(Map<String,Object> me, MessageType mt, byte[] codecids)
me - The message content (name value pairs).mt - The message type describing the content.public IFuture<Void> sendMessageAndWait(Map<String,Object> 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 Map<String,Object> createReply(Map<String,Object> msg, MessageType mt)
msgeventtype - The message event type.public String getAgentName()
public IComponentIdentifier getComponentIdentifier()
getComponentIdentifier in interface IInternalAccesspublic <T> IFuture<T> scheduleStep(IComponentStep<T> step)
step - Code to be executed as a step of the agent.public IFuture<Void> 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<Void> addService(String name, Class<?> type, Object service)
type - The public service interface.service - The service.public IFuture<Void> removeService(IServiceIdentifier sid)
service - The service.public <T> IFuture<T> waitForDelay(long delay, IComponentStep<T> step)
waitForDelay in interface IInternalAccesspublic IModelInfo getModel()
getModel in interface IInternalAccesspublic IFuture<Collection<IExternalAccess>> getChildrenAccesses()
getChildrenAccesses in interface IInternalAccesspublic IFuture<IComponentIdentifier[]> getChildrenIdentifiers()
getChildrenIdentifiers in interface IInternalAccesspublic IFuture<Map<String,Object>> killComponent()
killComponent in interface IInternalAccesspublic IFuture<Void> addComponentListener(IComponentListener listener)
addComponentListener in interface IInternalAccesslistener - The listener.public IFuture<Void> removeComponentListener(IComponentListener listener)
removeComponentListener in interface IInternalAccesslistener - The listener.public <T> IFuture<T> getRequiredService(String name)
name - The service name.public <T> IIntermediateFuture<T> getRequiredServices(String name)
name - The services name.public IServiceContainer createServiceContainer(Map<String,Object> args)
public IValueFetcher getFetcher()
getFetcher in interface IInternalAccesspublic ClassLoader getClassLoader()
getClassLoader in interface IInternalAccesspublic MicroAgentInterpreter getInterpreter()
public boolean isComponentThread()
isComponentThread in interface IInternalAccessCopyright © 2012. All Rights Reserved.