sofastack / sofa-rpc

SOFARPC is a high-performance, high-extensibility, production-level Java RPC framework.
https://www.sofastack.tech/sofa-rpc/docs/Home
Apache License 2.0
3.81k stars 1.17k forks source link

如何获取@SofaService注解生成的代理对象 #1246

Closed van0314 closed 1 year ago

van0314 commented 1 year ago

如何获取@SofaService注解生成的代理对象

我希望在服务运行中动态修改服务实例的一些属性。所以做了以下操作: 1.使用ApplicationContext.getBean(XXX.class)获取spring管理的服务实例; 2.通过反射修改服务实例属性; 但似乎并不生效。跟踪后发现通过sofaRPC调用的服务实例与spring容器中获取的服务实例不是同一个对象。 我该如何获取sofRPC的服务实例来实现动态修改其属性。

环境:

EvenLjj commented 1 year ago

@van0314 The bean name generated by SofaService has changed by com.alipay.sofa.runtime.spring.bean.SofaBeanNameGenerator#generateSofaServiceBeanName(java.lang.Class<?>, java.lang.String) and addDependsOn the orgin bean.So the way you get may not the true you want. If you have other questions, you can raise the issue in sofaboot. More professional personnel on sofaboot will answer this question for you.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.