
com.alibaba.dubbo.rpc.ServiceClassHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dubbo2 Show documentation
Show all versions of dubbo2 Show documentation
The all in one project of dubbo2
The newest version!
package com.alibaba.dubbo.rpc;
/**
* TODO this is just a workround for rest protocol, and now we just ensure it works in the most common dubbo usages
*
* @author lishen
*/
public class ServiceClassHolder {
private static final ServiceClassHolder INSTANCE = new ServiceClassHolder();
private final ThreadLocal holder = new ThreadLocal();
public static ServiceClassHolder getInstance() {
return INSTANCE;
}
private ServiceClassHolder() {
}
public Class popServiceClass() {
Class clazz = holder.get();
holder.remove();
return clazz;
}
public void pushServiceClass(Class clazz) {
holder.set(clazz);
}
}