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

xyz.erupt.core.proxy.ProxyContext Maven / Gradle / Ivy

There is a newer version: 1.12.17
Show newest version
package xyz.erupt.core.proxy;

import lombok.Getter;
import lombok.Setter;

import java.lang.reflect.Field;

/**
 * 代理类上下文
 *
 * @author YuePeng
 * date 2022/3/12 00:13
 */
@Getter
@Setter
public class ProxyContext {

    private static final ThreadLocal proxyContextThreadLocal = ThreadLocal.withInitial(ProxyContext::new);

    private Class clazz;

    private Field field;

    public static void set(Class clazz) {
        proxyContextThreadLocal.get().setClazz(clazz);
    }

    public static void set(Field field) {
        proxyContextThreadLocal.get().setField(field);
    }

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

    public static ProxyContext get() {
        return proxyContextThreadLocal.get();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy