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 |
---|---|
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,
PublishInfo pi)
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.
|
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.
|
IFuture<INFPropertyMetaInfo> |
getNfPropertyMetaInfo(String name)
Returns the meta information about a non-functional property of this service.
|
IFuture<String[]> |
getNonFunctionalPropertyNames()
Returns the names of all non-functional properties of this service.
|
<T> IFuture<T> |
getNonFunctionalPropertyValue(String name)
Returns the current value of a non-functional property of this service, performs unit conversion.
|
<T,U> IFuture<T> |
getNonFunctionalPropertyValue(String name,
Class<U> unit)
Returns the current value of a non-functional property of this service, performs unit conversion.
|
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.
|
INFMixedPropertyProvider |
getRequiredServicePropertyProvider(IServiceIdentifier sid)
Get the required service property provider for a service.
|
<T> ITerminableIntermediateFuture<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.
|
boolean |
hasEventTargets(IMonitoringService.PublishTarget pt,
IMonitoringService.PublishEventLevel pi)
Check if event targets exist.
|
boolean |
hasRequiredServicePropertyProvider(IServiceIdentifier sid)
Has the service a property provider.
|
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> |
publishEvent(IMonitoringEvent event,
IMonitoringService.PublishTarget pt)
Publish a monitoring event.
|
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.
|
<T> IFuture<T> |
scheduleStep(IComponentStep<T> step,
long delay)
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.
|
ISubscriptionIntermediateFuture<IMonitoringEvent> |
subscribeToEvents(IFilter<IMonitoringEvent> filter,
boolean initial,
IMonitoringService.PublishEventLevel elm)
Subscribe to component events.
|
IFuture<ITimer> |
waitFor(long time,
IComponentStep<Void> step)
Wait for an specified amount of time.
|
IFuture<ITimer> |
waitFor(long time,
IComponentStep<Void> step,
boolean realtime)
Wait for an specified amount of time.
|
IFuture<Void> |
waitForDelay(long delay)
Wait for some time.
|
IFuture<Void> |
waitForDelay(long delay,
boolean realtime)
Wait for some time.
|
<T> IFuture<T> |
waitForDelay(long delay,
IComponentStep<T> step)
Wait for some time and execute a component step afterwards.
|
<T> IFuture<T> |
waitForDelay(long delay,
IComponentStep<T> step,
boolean realtime)
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 IMicroAgent
public IFuture<Void> executeBody()
executeBody
in interface IMicroAgent
public void messageArrived(Map<String,Object> msg, MessageType mt)
messageArrived
in interface IMicroAgent
msg
- The message.mt
- The message type.public void streamArrived(IConnection con)
con
- The stream.public IFuture<Void> 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 getParentAccess()
getParentAccess
in interface IInternalAccess
public IComponentAdapter getAgentAdapter()
public IComponentAdapter getComponentAdapter()
public IComponentDescription getComponentDescription()
getComponentDescription
in interface IInternalAccess
public Map<String,Object> getArguments()
getArguments
in interface IInternalAccess
public Map<String,Object> 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(String name)
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<ITimer> waitFor(long time, IComponentStep<Void> step)
time
- The time.step
- The runnable.public IFuture<ITimer> waitFor(long time, IComponentStep<Void> step, boolean realtime)
time
- The time.step
- The runnable.public IFuture<MicroAgent.TimerWrapper> waitForTick(IComponentStep<Void> run)
time
- The time.public Logger getLogger()
getLogger
in interface IInternalAccess
public 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 IInternalAccess
public <T> IFuture<T> scheduleStep(IComponentStep<T> step)
step
- Code to be executed as a step of the agent.public <T> IFuture<T> scheduleStep(IComponentStep<T> step, long delay)
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> addService(String name, Class<?> type, Object service, PublishInfo pi)
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 IInternalAccess
public <T> IFuture<T> waitForDelay(long delay, IComponentStep<T> step, boolean realtime)
waitForDelay
in interface IInternalAccess
public IFuture<Void> waitForDelay(long delay)
waitForDelay
in interface IInternalAccess
public IFuture<Void> waitForDelay(long delay, boolean realtime)
waitForDelay
in interface IInternalAccess
public IModelInfo getModel()
getModel
in interface IInternalAccess
public IFuture<Map<String,Object>> killComponent()
killComponent
in interface IInternalAccess
public <T> IFuture<T> getRequiredService(String name)
name
- The service name.public <T> ITerminableIntermediateFuture<T> getRequiredServices(String name)
name
- The services name.public IServiceContainer createServiceContainer(Map<String,Object> args)
public IValueFetcher getFetcher()
getFetcher
in interface IInternalAccess
public ClassLoader getClassLoader()
getClassLoader
in interface IInternalAccess
public MicroAgentInterpreter getInterpreter()
public boolean isComponentThread()
isComponentThread
in interface IInternalAccess
public IFuture<Void> publishEvent(IMonitoringEvent event, IMonitoringService.PublishTarget pt)
publishEvent
in interface IInternalAccess
public ISubscriptionIntermediateFuture<IMonitoringEvent> subscribeToEvents(IFilter<IMonitoringEvent> filter, boolean initial, IMonitoringService.PublishEventLevel elm)
subscribeToEvents
in interface IInternalAccess
filter
- An optional filter.initial
- True, for receiving the current state.public IFuture<String[]> getNonFunctionalPropertyNames()
public IFuture<INFPropertyMetaInfo> getNfPropertyMetaInfo(String name)
name
- Name of the property.public <T> IFuture<T> getNonFunctionalPropertyValue(String name)
name
- Name of the property.type
- Type of the property value.public <T,U> IFuture<T> getNonFunctionalPropertyValue(String name, Class<U> unit)
name
- Name of the property.type
- Type of the property value.unit
- Unit of the property value.public INFMixedPropertyProvider getRequiredServicePropertyProvider(IServiceIdentifier sid)
public boolean hasRequiredServicePropertyProvider(IServiceIdentifier sid)
public boolean hasEventTargets(IMonitoringService.PublishTarget pt, IMonitoringService.PublishEventLevel pi)
hasEventTargets
in interface IInternalAccess
Copyright © 2013. All Rights Reserved.