com.xlrit.gears.base.execution.AbstractBehavior Maven / Gradle / Ivy
package com.xlrit.gears.base.execution;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.springframework.beans.factory.annotation.Autowired;
public abstract class AbstractBehavior implements org.flowable.engine.delegate.JavaDelegate {
@Autowired
private ExecutionFactory executionFactory;
public void execute(org.flowable.engine.delegate.DelegateExecution delegate) {
ExecutionEntity executionEntity = (ExecutionEntity) delegate;
String loggerName = "process." + executionEntity.getProcessDefinitionKey() + "." + getClass().getSimpleName();
Execution execution = executionFactory.wrap(delegate, loggerName);
long startTime = System.currentTimeMillis();
execute(execution);
execution.flush();
long elapsed = System.currentTimeMillis() - startTime;
execution.getLogger().debug("Executed in {} seconds", String.format("%.2f", elapsed / 1000f));
}
protected abstract void execute(Execution execution);
}