jadex.bpmn.runtime.task.DestroyComponentTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jadex-kernel-bpmn Show documentation
Show all versions of jadex-kernel-bpmn Show documentation
The Jadex BPMN kernel provides a workflow kernel for the standardized business process modeling notation. The kernel relies on annotated BPMN diagrams, which include detailed execution information.
package jadex.bpmn.runtime.task;
import java.util.Map;
import jadex.bpmn.model.task.ITask;
import jadex.bpmn.model.task.ITaskContext;
import jadex.bpmn.model.task.annotation.Task;
import jadex.bpmn.model.task.annotation.TaskParameter;
import jadex.bridge.BasicComponentIdentifier;
import jadex.bridge.IComponentIdentifier;
import jadex.bridge.IInternalAccess;
import jadex.bridge.component.IExecutionFeature;
import jadex.bridge.service.RequiredServiceInfo;
import jadex.bridge.service.search.SServiceProvider;
import jadex.bridge.service.types.cms.IComponentManagementService;
import jadex.commons.future.ExceptionDelegationResultListener;
import jadex.commons.future.Future;
import jadex.commons.future.IFuture;
import jadex.commons.future.IResultListener;
/**
* Task for destroying a component.
*/
@Task(description="The destroy component task can be used for killing a specific component.", parameters={
@TaskParameter(name="componentid", clazz=IComponentIdentifier.class, direction=TaskParameter.DIRECTION_IN,
description="The componentid parameter serves for specifying the component id."),
@TaskParameter(name="name", clazz=String.class, direction=TaskParameter.DIRECTION_IN,
description= "The name parameter serves for specifying the local component name (if id not available)."),
@TaskParameter(name="resultlistener", clazz=IResultListener.class, direction=TaskParameter.DIRECTION_IN,
description="The componentid parameter serves for specifying the component id."),
@TaskParameter(name="wait", clazz=boolean.class, direction=TaskParameter.DIRECTION_IN,
description="The wait parameter specifies is the activity should wait for the component being killed." +
"This is e.g. necessary if the return values should be used.")
})
public class DestroyComponentTask implements ITask
{
/**
* Execute the task.
*/
public IFuture execute(final ITaskContext context, final IInternalAccess instance)
{
final Future ret = new Future();
SServiceProvider.getService(instance, IComponentManagementService.class, RequiredServiceInfo.SCOPE_PLATFORM)
.addResultListener(instance.getComponentFeature(IExecutionFeature.class).createResultListener(new ExceptionDelegationResultListener(ret)
{
public void customResultAvailable(IComponentManagementService cms)
{
final IResultListener resultlistener = (IResultListener)context.getParameterValue("resultlistener");
final boolean wait = context.getParameterValue("wait")!=null? ((Boolean)context.getParameterValue("wait")).booleanValue(): false;
IComponentIdentifier cid = (IComponentIdentifier)context.getParameterValue("componentid");
if(cid==null)
{
String name = (String)context.getParameterValue("name");
// cid = ces.createComponentIdentifier(name, true, null);
if(name.indexOf("@")==-1)
cid = new BasicComponentIdentifier(name);
else
cid = new BasicComponentIdentifier(name, instance.getComponentIdentifier().getParent());
}
IFuture