我有几个无状态 bean 和一些由该 bean 调用的服务类。我不能直接将 bean 实例传递给该服务类。
有什么方法可以获取当前正在执行的 bean 实例?我只是想知道是否有任何现有的机制,所以我不需要编写拦截器和相关逻辑来将 bean 实例保存在某个地方。
更加具体:
public class MyBean implements MyBeanInterface, CommonBeanInterface {
     public void businessMethod() {
         SomeService service = ... // service is somehow obtained
         service.doWork();
     }
}
public class SomeServiceImpl implements SomeService {
     public void doWork() {
          CommonBeanInterface currentBean = getCurrentBean(); // its implementation I need
     }
}
因此,在服务类中,我需要获取调用此服务的 bean 实例。
任何信息都有帮助!