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

org.zodiac.datasource.jdbc.transaction.TransactionIdHolder Maven / Gradle / Ivy

The newest version!
package org.zodiac.datasource.jdbc.transaction;

import org.zodiac.sdk.toolkit.util.lang.StrUtil;

public class TransactionIdHolder {

    private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>();

    public static String getXID() {
        String xid = CONTEXT_HOLDER.get();
        if (StrUtil.isNotEmpty(xid)) {
            return xid;
        }
        return null;
    }

    public static String unbind(String xid) {
        CONTEXT_HOLDER.remove();
        return xid;
    }

    public static String bind(String xid) {
        CONTEXT_HOLDER.set(xid);
        return xid;
    }

    public static void remove() {
        CONTEXT_HOLDER.remove();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy