jadex.micro.testcases.pull.PullResultProviderAgent 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.pull;
import jadex.bridge.IInternalAccess;
import jadex.bridge.service.annotation.Service;
import jadex.commons.ICommand;
import jadex.commons.future.IPullIntermediateFuture;
import jadex.commons.future.IPullSubscriptionIntermediateFuture;
import jadex.commons.future.PullIntermediateFuture;
import jadex.commons.future.PullSubscriptionIntermediateFuture;
import jadex.commons.future.TerminationCommand;
import jadex.micro.annotation.Agent;
import jadex.micro.annotation.Description;
import jadex.micro.annotation.Implementation;
import jadex.micro.annotation.ProvidedService;
import jadex.micro.annotation.ProvidedServices;
/**
* Agent that provides a service with intermediate results.
*/
@Agent
@Service
@ProvidedServices(@ProvidedService(type=IPullResultService.class, implementation=@Implementation(expression="$pojoagent")))
@Description("Agent that provides a service with intermediate results")
public class PullResultProviderAgent implements IPullResultService
{
//-------- attributes ---------
/** The agent. */
@Agent
protected IInternalAccess agent;
//-------- constructors ---------
/**
* Get the results.
* @param max The number of intermediate results that will be returned.
* @return The results.
*/
public IPullIntermediateFuture getResultsA(final int max)
{
final PullIntermediateFuture ret = new PullIntermediateFuture(
new ICommand>()
{
int cnt = 0;
public void execute(PullIntermediateFuture fut)
{
if(cnt getResultsB(final int max)
{
final PullSubscriptionIntermediateFuture ret = new PullSubscriptionIntermediateFuture(
new ICommand>()
{
int cnt = 0;
public void execute(PullSubscriptionIntermediateFuture fut)
{
if(cnt