com.atomikos.icatch.jta.template.SupportsTemplate Maven / Gradle / Ivy
/**
* Copyright (C) 2000-2023 Atomikos
*
* LICENSE CONDITIONS
*
* See http://www.atomikos.com/Main/WhichLicenseApplies for details.
*/
package com.atomikos.icatch.jta.template;
import java.util.concurrent.Callable;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
class SupportsTemplate extends TransactionTemplate {
public SupportsTemplate(TransactionManager utm, int timeout) {
super(utm, timeout);
}
public T execute(Callable work) throws Exception {
Transaction existingTransaction = utm.getTransaction();
if (existingTransaction != null) {
return super.execute(work);
} else {
return work.call();
}
}
}