jadex.bpmn.runtime.ExecuteProcessThread 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;
import java.util.List;
import jadex.bpmn.features.IBpmnComponentFeature;
import jadex.bpmn.features.impl.BpmnComponentFeature;
import jadex.bpmn.model.MActivity;
import jadex.bridge.IConditionalComponentStep;
import jadex.bridge.IConnection;
import jadex.bridge.IInternalAccess;
import jadex.commons.IFilter;
import jadex.commons.future.IFuture;
/**
* Execute the next step of a process thread.
*/
public class ExecuteProcessThread implements IConditionalComponentStep
{
/** The process thread. */
protected ProcessThread thread;
/** The thread id. Needed for bpmn debugger. */
protected String threadid;
/**
* Create a new step.
* @param thread The thread.
*/
public ExecuteProcessThread(ProcessThread thread)
{
this.thread = thread;
this.threadid = thread.getId();
// System.out.println("created step for: "+thread.getId()+" "+thread.getActivity());
}
/**
* Test if the action is valid.
* @return True, if action is valid.
*/
public boolean isValid()
{
// Can be set to null when thread is removed (e.g. termination of component)
boolean ret = thread.getActivity()!=null && !thread.isWaiting();
// if(!ret)
// System.out.println("not exe: "+thread.getInstance().getComponentIdentifier().getLocalName()+" "+thread);
return ret;
}
/**
* Execute the command.
* @param args The argument(s) for the call.
* @return The result of the command.
*/
public IFuture execute(IInternalAccess ia)
{
BpmnComponentFeature bcf = (BpmnComponentFeature)thread.getInstance().getComponentFeature(IBpmnComponentFeature.class);
// Update parameters based on edge inscriptions and initial values.
thread.updateParametersBeforeStep(thread.getInstance());
// Find handler and execute activity.
IActivityHandler handler = (IActivityHandler)bcf.getActivityHandler(thread.getActivity());
// IActivityHandler handler = (IActivityHandler)activityhandlers.get(thread.getActivity().getActivityType());
if(handler==null)
throw new UnsupportedOperationException("No handler for activity: "+thread);
// System.out.println("step: "+getComponentIdentifier()+" "+thread.getId()+" "+thread.getActivity()+" "+thread.getActivity().getId());
MActivity act = thread.getActivity();
// notifyListeners(createActivityEvent(IComponentChangeEvent.EVENT_TYPE_CREATION, thread, thread.getActivity()));
// if(thread.getInstance().getComponentFeature0(IMonitoringComponentFeature.class)!=null && thread.getInstance().getComponentFeature(IMonitoringComponentFeature.class).hasEventTargets(PublishTarget.TOALL, PublishEventLevel.FINE))
// thread.getInstance().getComponentFeature(IMonitoringComponentFeature.class).publishEvent(bcf.createActivityEvent(IMonitoringEvent.EVENT_TYPE_CREATION, thread, thread.getActivity()), PublishTarget.TOALL);
// thread = handler.execute(act, this, thread);
handler.execute(act, thread.getInstance(), thread);
// Moved to StepHandler
// thread.updateParametersAfterStep(act, this);
// Check if thread now waits for a message and there is at least one in the message queue.
// Todo: check if thread directly or indirectly (multiple events!) waits for a message event before checking waitqueue
List