jadex.micro.testcases.multiinvoke.ProviderAgent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-micro Show documentation
Show all versions of jadex-applications-micro Show documentation
The Jadex micro applications package contains several example applications, benchmarks and testcases using micro agents.
package jadex.micro.testcases.multiinvoke;
import jadex.bridge.IComponentStep;
import jadex.bridge.IInternalAccess;
import jadex.bridge.component.IExecutionFeature;
import jadex.bridge.service.annotation.Service;
import jadex.bridge.service.annotation.ServiceComponent;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;
import jadex.commons.future.IIntermediateFuture;
import jadex.commons.future.IntermediateFuture;
import jadex.micro.annotation.Agent;
import jadex.micro.annotation.Implementation;
import jadex.micro.annotation.ProvidedService;
import jadex.micro.annotation.ProvidedServices;
/**
* Simple test agent with one service.
*/
@ProvidedServices(@ProvidedService(type=IExampleService.class,
implementation=@Implementation(expression="$pojoagent")))
//@Results(@Result(name="testcases", clazz=List.class))
@Service(IExampleService.class)
@Agent
public class ProviderAgent implements IExampleService
{
@ServiceComponent
protected IInternalAccess agent;
/**
* Get an item.
*/
public IFuture getItem()
{
return new Future("item: "+agent.getComponentIdentifier().getName());
}
/**
* Get the items.
*/
public IIntermediateFuture getItems(final int num)
{
final IntermediateFuture ret = new IntermediateFuture();
final int cnt[] = new int[1];
final long delay = 1000;
IComponentStep step = new IComponentStep()
{
public IFuture execute(IInternalAccess ia)
{
if(cnt[0]++ add(int a, int b)
{
return new Future(Integer.valueOf(a+b));
}
}