use of org.drools.persistence.api.TransactionAware in project jbpm by kiegroup.
the class TaskTransactionInterceptor method execute.
@Override
public synchronized RequestContext execute(Executable executable, RequestContext ctx) {
boolean transactionOwner = false;
try {
transactionOwner = txm.begin();
tpm.beginCommandScopedEntityManager();
TransactionManagerHelper.registerTransactionSyncInContainer(this.txm, new TaskSynchronizationImpl(this));
if (txm != null) {
ObjectMarshallingStrategy[] strategies = (ObjectMarshallingStrategy[]) environment.get(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES);
if (strategies != null) {
for (ObjectMarshallingStrategy strategy : strategies) {
if (strategy instanceof TransactionAware) {
((TransactionAware) strategy).onStart(txm);
}
}
}
}
RequestContext context = createContext();
executeNext(executable, context);
ctx.setResult(context.getResult());
postInit(ctx.getResult());
txm.commit(transactionOwner);
return ctx;
} catch (TaskException e) {
// if transaction is owned by other component like process engine
if (transactionOwner) {
rollbackTransaction(e, transactionOwner);
e.setRecoverable(false);
throw e;
} else {
throw e;
}
} catch (RuntimeException re) {
rollbackTransaction(re, transactionOwner);
throw re;
} catch (Exception t1) {
rollbackTransaction(t1, transactionOwner);
throw new RuntimeException("Wrapped exception see cause", t1);
}
}
Aggregations