All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.micro.testcases.multiinvoke.ProviderAgent Maven / Gradle / Ivy

Go to download

The Jadex micro applications package contains several example applications, benchmarks and testcases using micro agents.

There is a newer version: 4.0.267
Show newest version
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));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy