jadex.platform.service.email.EmailFetcherAgent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-platform Show documentation
Show all versions of jadex-platform Show documentation
The Jadex platform package contains implementations of platform services as well as the platform component itself.
package jadex.platform.service.email;
import java.util.List;
import jadex.bridge.IComponentStep;
import jadex.bridge.IInternalAccess;
import jadex.bridge.component.IExecutionFeature;
import jadex.bridge.service.annotation.Service;
import jadex.bridge.service.types.email.Email;
import jadex.commons.future.IFuture;
import jadex.commons.future.IIntermediateFuture;
import jadex.commons.future.IntermediateFuture;
import jadex.micro.annotation.Agent;
/**
* Agent that is responsible for fetching mails for one subscription.
*/
@Agent(autoprovide=true)
@Service
public class EmailFetcherAgent implements IEmailFetcherService
{
/** The agent. */
@Agent
protected IInternalAccess agent;
/**
* Fetch emails for a subscription.
* @param sub The subscription.
* @return The emails.
*/
public IIntermediateFuture fetchEmails(SubscriptionInfo sub)
{
List emails = sub.getNewEmails();
// Hack, needed because pool cannot be used (pro)
agent.getComponentFeature(IExecutionFeature.class).scheduleStep(new IComponentStep()
{
public IFuture execute(IInternalAccess ia)
{
// System.out.println("kill: "+agent);
agent.killComponent();
return IFuture.DONE;
}
});
return new IntermediateFuture(emails);
}
}