jadex.bdi.planlib.protocols.cancelmeta.CMInitiatorPlan Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-applications-applib-bdi Show documentation
Show all versions of jadex-applications-applib-bdi Show documentation
The Jadex applib BDI package contains ready to use functionalities for BDI agents mostly in form of modules called capabilities.
The newest version!
package jadex.bdi.planlib.protocols.cancelmeta;
import java.util.Iterator;
import java.util.List;
import jadex.bdi.planlib.protocols.InteractionState;
import jadex.bdiv3x.runtime.IMessageEvent;
import jadex.bdiv3x.runtime.Plan;
import jadex.bridge.ComponentNotFoundException;
import jadex.bridge.IComponentIdentifier;
import jadex.bridge.fipa.SFipa;
import jadex.bridge.service.annotation.Timeout;
import jadex.commons.SUtil;
import jadex.commons.TimeoutException;
/**
* Plan to handle protocol abortion according to FIPA cancel meta protocol
*/
public class CMInitiatorPlan extends Plan
{
public void body()
{
// Try to abort the interaction using FIPA-Cancel-Meta-Protocol.
// Results of cancellation will be stored in interaction state (if any).
InteractionState state = null;
if(hasParameter("interaction_state"))
state = (InteractionState)getParameter("interaction_state").getValue();
// Copy message properties from initial message.
IMessageEvent message = (IMessageEvent)getParameter("message").getValue();
IMessageEvent cancel = createMessageEvent("cm_cancel");
cancel.getParameterSet(SFipa.RECEIVERS).addValues(message.getParameterSet(SFipa.RECEIVERS).getValues());
cancel.getParameter(SFipa.CONVERSATION_ID).setValue(message.getParameter(SFipa.CONVERSATION_ID).getValue());
cancel.getParameter(SFipa.LANGUAGE).setValue(message.getParameter(SFipa.LANGUAGE).getValue());
cancel.getParameter(SFipa.ONTOLOGY).setValue(message.getParameter(SFipa.ONTOLOGY).getValue());
// Use extra reply_with to avoid intermingling with other protocol messages.
cancel.getParameter(SFipa.REPLY_WITH).setValue(SUtil.createUniqueId(getComponentName()));
// Send cancel message to participants.
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy