jadex.bpmn.features.impl.BpmnMessageComponentFeature 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.features.impl;
import java.util.Iterator;
import jadex.bpmn.features.IBpmnComponentFeature;
import jadex.bpmn.features.IInternalBpmnComponentFeature;
import jadex.bpmn.runtime.ProcessThread;
import jadex.bridge.IComponentStep;
import jadex.bridge.IConnection;
import jadex.bridge.IInternalAccess;
import jadex.bridge.IMessageAdapter;
import jadex.bridge.component.ComponentCreationInfo;
import jadex.bridge.component.IComponentFeatureFactory;
import jadex.bridge.component.IMessageFeature;
import jadex.bridge.component.impl.ComponentFeatureFactory;
import jadex.bridge.component.impl.MessageComponentFeature;
import jadex.commons.IFilter;
/**
* Extension to allow message injection in agent methods.
*/
public class BpmnMessageComponentFeature extends MessageComponentFeature
{
//-------- constants --------
/** The factory. */
public static final IComponentFeatureFactory FACTORY = new ComponentFeatureFactory(IMessageFeature.class, BpmnMessageComponentFeature.class);
//-------- constructors --------
/**
* Create the feature.
*/
public BpmnMessageComponentFeature(IInternalAccess component, ComponentCreationInfo cinfo)
{
super(component, cinfo);
}
//-------- IInternalMessageFeature interface --------
/**
* Helper method to override message handling.
* May be called from external threads.
*/
protected IComponentStep createHandleMessageStep(IMessageAdapter message)
{
return new HandleBpmnMessageStep(message);
}
/**
* Step to handle a message.
*/
public class HandleBpmnMessageStep extends HandleMessageStep
{
public HandleBpmnMessageStep(IMessageAdapter message)
{
super(message);
}
/**
* Extracted to allow overriding behaviour.
* @return true, when at least one matching handler was found.
*/
protected boolean invokeHandlers(IMessageAdapter message)
{
boolean ret = super.invokeHandlers(message);
// System.out.println("rec msg: "+message);
if(!ret)
{
IInternalBpmnComponentFeature bcf = (IInternalBpmnComponentFeature)getComponent().getComponentFeature(IBpmnComponentFeature.class);
// Iterate through process threads and dispatch message to first
// waiting and fitting one (filter check).
boolean processed = false;
for(Iterator it=bcf.getTopLevelThread().getAllThreads().iterator(); it.hasNext() && !processed; )
{
ProcessThread pt = it.next();
if(pt.isWaiting())
{
IFilter