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

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

There is a newer version: 6.0.0
Show newest version
/**
 * 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 NeverTemplate extends TransactionTemplate {

    public NeverTemplate(TransactionManager utm, int timeout) {
       super(utm, timeout);
    }
    
    public  T execute(Callable work) throws Exception {
        Transaction existingTransaction = utm.getTransaction();
        if (existingTransaction != null) {
            throw new IllegalStateException("A transaction exists but none is allowed.");
        }
        return work.call();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy