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

jadex.bdi.planlib.cms.CMSLocalCreateComponentPlan Maven / Gradle / Ivy

Go to download

The Jadex applib BDI package contain ready to use functionalities for BDI agents mostly in form of modules called capabilities.

There is a newer version: 2.4
Show newest version
package jadex.bdi.planlib.cms;

import jadex.bdi.runtime.Plan;
import jadex.bridge.CreationInfo;
import jadex.bridge.IComponentIdentifier;
import jadex.bridge.IComponentManagementService;
import jadex.commons.future.IFuture;

import java.util.Map;

/**
 *  Plan for creating a Jadex component on the platform.
 */
public class CMSLocalCreateComponentPlan extends Plan
{

	/**
	 *  Execute a plan.
	 */
	public void body()
	{
		String	type	= (String)getParameter("type").getValue();
		String	name	= (String)getParameter("name").getValue();
		String	config	= (String)getParameter("configuration").getValue();
		Map	args	= (Map)getParameter("arguments").getValue();
		Boolean	suspend	= (Boolean)getParameter("suspend").getValue();
		Boolean	master	= (Boolean)getParameter("master").getValue();
		IComponentIdentifier	parent	= (IComponentIdentifier)getParameter("parent").getValue();

		try
		{
			// todo: support parent/master etc.
			IFuture ret = ((IComponentManagementService)getServiceContainer().getRequiredService("cms").get(this))
				.createComponent(name, type, new CreationInfo(config, args, parent, suspend, master), null);
			IComponentIdentifier aid = (IComponentIdentifier)ret.get(this);
			getParameter("componentidentifier").setValue(aid);
		}
		catch(Exception e)
		{
//			e.printStackTrace();
			fail(e); // Do not show exception on console. 
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy