1、获取当前线程pid--dubbo源码
private static int PID = -1;
public static int getPid() {
if (PID < 0) {
try {
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
String name = runtime.getName(); // format: "pid@hostname"
PID = Integer.parseInt(name.substring(0, name.indexOf('@')));
} catch (Throwable e) {
PID = 0;
}
}
return PID;
}
2、spring解析 Autowired和Value注解类
AutowiredAnnotationBeanPostProcessor
本文详细介绍了Dubbo源码中获取当前线程进程ID的方法,通过ManagementFactory.getRuntimeMXBean()获取运行时信息,并解析出PID。同时,深入讲解了Spring框架中AutowiredAnnotationBeanPostProcessor类如何解析@Autowired和@Value注解,实现依赖注入。
2444

被折叠的 条评论
为什么被折叠?



