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

jadex.micro.tutorial.ChatC3Agent 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.tutorial;

import jadex.bridge.IInternalAccess;
import jadex.bridge.service.component.IRequiredServicesFeature;
import jadex.bridge.service.types.cms.IComponentDescription;
import jadex.bridge.service.types.cms.IComponentManagementService;
import jadex.commons.future.DefaultResultListener;
import jadex.commons.future.IFuture;
import jadex.micro.annotation.Agent;
import jadex.micro.annotation.AgentBody;
import jadex.micro.annotation.AgentFeature;
import jadex.micro.annotation.Binding;
import jadex.micro.annotation.Description;
import jadex.micro.annotation.RequiredService;
import jadex.micro.annotation.RequiredServices;

/**
 *  Chat micro agent that uses the clock service. 
 */
@Description("This agent uses the component management service.")
@Agent
@RequiredServices(@RequiredService(name="cms", type=IComponentManagementService.class, 
	binding=@Binding(scope=Binding.SCOPE_PLATFORM)))
public class ChatC3Agent
{
	/** The required services feature. */
	@AgentFeature
	protected IRequiredServicesFeature requiredServicesFeature;
	
	/**
	 *  Execute the functional body of the agent.
	 *  Is only called once.
	 */
	@AgentBody
	public void executeBody()
	{
		IFuture	cms	= requiredServicesFeature.getRequiredService("cms");
		cms.addResultListener(new DefaultResultListener()
		{
			public void resultAvailable(final IComponentManagementService cms)
			{
				cms.getComponentDescriptions().addResultListener(
					new DefaultResultListener()
				{
					public void resultAvailable(IComponentDescription[] descs)
					{
						for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy