com.isuwang.soa.core.InvocationContext Maven / Gradle / Ivy
package com.isuwang.soa.core;
import java.util.Optional;
/**
* 客户端上下文
*
* @author craneding
* @date 15/9/24
*/
public class InvocationContext extends Context {
public static class Factory {
private static ThreadLocal threadLocal = new ThreadLocal<>();
private static ISoaHeaderProxy soaHeaderProxy;
public static interface ISoaHeaderProxy {
Optional callerFrom();
Optional customerId();
Optional customerName();
Optional operatorId();
Optional operatorName();
}
public static void setSoaHeaderProxy(ISoaHeaderProxy soaHeaderProxy) {
Factory.soaHeaderProxy = soaHeaderProxy;
}
public static ISoaHeaderProxy getSoaHeaderProxy() {
return soaHeaderProxy;
}
public static InvocationContext getNewInstance() {
return new InvocationContext();
}
public static InvocationContext setCurrentInstance(InvocationContext context) {
threadLocal.set(context);
return context;
}
public static InvocationContext getCurrentInstance() {
InvocationContext context = threadLocal.get();
if (context == null) {
context = getNewInstance();
threadLocal.set(context);
}
return context;
}
public static void removeCurrentInstance() {
threadLocal.remove();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy