Should be an easy task with process engine of 6.0 and upwards. Be aware that the shown example uses non-public API and that it can change without any notice.
The following code show a custom engine execution listener that logs the data and process element PID of every element that is executed:
public class ExecListener {
public static void install()
{
IBpmEngine engine = DiCore.getGlobalInjector().getInstance(IBpmEngine.class);
engine.getHistory().addElementHistoryListener(new LoggingListener(Ivy.log()));
}
private static class LoggingListener implements IElementHistoryListener
{
private final Logger logger;
public LoggingListener(Logger logger) {
this.logger = logger;
}
@Override
public void elementExecutionHistoryAdded(IElementExecutionHistory executionHistory) {
PID pid = executionHistory.getElementRequestHistory().getElementHistory().getProcessElementId();
logger.info("executing element pid: "+pid);
Object in = executionHistory.getData().getAttributeValue("in");
if (in instanceof Data)
{
Data data = (Data)in;
logger.info(data);
}
}
}
}
I've created a simple demo project here: http://developer.axonivy.com/q-and-a-attachments/engineExecutionListener_641.iarhttps://answers.axonivy.com/upfiles/engineExecutionListener_641.iar
![alt text][1]
[1]: http://answers.axonivy.com/upfiles/bpmEngineListenerLog.PNGhttps://answers.axonivy.com/upfiles/bpmEngineListenerLog.PNG