jadex.micro.tutorial.PrintTimeStep 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.tutorial;
import java.util.Date;
import jadex.bridge.IComponentStep;
import jadex.bridge.IInternalAccess;
import jadex.bridge.service.component.IRequiredServicesFeature;
import jadex.bridge.service.types.clock.IClockService;
import jadex.commons.future.DefaultResultListener;
import jadex.commons.future.IFuture;
/**
* Component step that prints the time.
*/
public class PrintTimeStep implements IComponentStep
{
/**
* Execute the command.
* @param args The argument(s) for the call.
* @return The result of the command.
*/
public IFuture execute(IInternalAccess ia)
{
IFuture fut = ia.getComponentFeature(IRequiredServicesFeature.class).getRequiredService("clockservice");
fut.addResultListener(new DefaultResultListener()
{
public void resultAvailable(IClockService cs)
{
// IClockService cs = (IClockService)result;
System.out.println("Time for a chat buddy: "+new Date(cs.getTime()));
}
});
return IFuture.DONE;
}
}