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

jadex.micro.examples.helloworld.PojoHelloWorldAgent 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.examples.helloworld;

import jadex.bridge.IComponentStep;
import jadex.bridge.IInternalAccess;
import jadex.bridge.component.IExecutionFeature;
import jadex.bridge.service.RequiredServiceInfo;
import jadex.bridge.service.search.SServiceProvider;
import jadex.bridge.service.types.clock.IClockService;
import jadex.commons.future.IFuture;
import jadex.micro.annotation.Agent;
import jadex.micro.annotation.AgentArgument;
import jadex.micro.annotation.AgentBody;
import jadex.micro.annotation.Argument;
import jadex.micro.annotation.Arguments;
import jadex.micro.annotation.Description;

/**
 *  The micro version of the hello world agent.
 */
@Agent
@Description("This agent prints out a hello message.")
@Arguments(@Argument(name="welcome text", description= "This parameter is the text printed by the agent.", 
	clazz=String.class, defaultvalue="\"Hello world, this is a Jadex micro agent.\""))
public class PojoHelloWorldAgent
{
	//-------- attributes --------
	
	/** The micro agent class. */
	@Agent
	protected IInternalAccess agent;
	
	/** The welcome text. */
	@AgentArgument("welcome text")
	protected String text;
	
	//-------- methods --------
	
	/**
	 *  Execute an agent step.
	 */
	@AgentBody
	public void executeBody()
	{
//		System.out.println(agent.getComponentFeature(IArgumentsFeature.class).getArgument("welcome text"));
		
//		IClockService cl = SServiceProvider.getLocalService(agent, IClockService.class, RequiredServiceInfo.SCOPE_PLATFORM);
//		System.out.println("clockservice: "+cl);
		
//		agent.getComponentFeature(IExecutionFeature.class).waitForDelay(2000, new IComponentStep()
//		{			
//			public IFuture execute(IInternalAccess ia)
//			{
//				System.out.println("Good bye world.");
//				agent.killComponent();
//				return IFuture.DONE;
//			}
//		});
		
		System.out.println(text);
		agent.getComponentFeature(IExecutionFeature.class).waitForDelay(2000).get();
		System.out.println("Good bye world.");
		agent.killComponent();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy