All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.atomikos.icatch.jta.template.RequiredTemplate Maven / Gradle / Ivy

There is a newer version: 6.0.0
Show newest version
/**
 * Copyright (C) 2000-2020 Atomikos 
 *
 * LICENSE CONDITIONS
 *
 * See http://www.atomikos.com/Main/WhichLicenseApplies for details.
 */

package com.atomikos.icatch.jta.template;

import java.lang.reflect.UndeclaredThrowableException;
import java.util.concurrent.Callable;

import javax.transaction.TransactionManager;

class RequiredTemplate extends TransactionTemplate {
    
    protected RequiredTemplate(TransactionManager utm, int timeout) {
        super(utm, timeout);
    }
    
    public  T execute(Callable work) throws Exception {
        T ret = null;
        try {
            beginTransactionIfNoneExists();
            ret = work.call();
            commitTransactionIfStartedHere();
        } catch (Exception e) {
            forceRollback(e);
            throw e;
        } catch (Throwable e) {
            forceRollback(e);
            throw new UndeclaredThrowableException(e);
        }
        return ret;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy