dangdangdotcom / dubbox

Dubbox now means Dubbo eXtensions, and it adds features like RESTful remoting, Kyro/FST serialization, etc to the Dubbo service framework.
http://dangdangdotcom.github.io/dubbox
Apache License 2.0
4.9k stars 2.06k forks source link

有什么办法能拿到所有使用了@Reference注解的ReferenceBean #160

Open whthomas opened 8 years ago

whthomas commented 8 years ago

如果是使用xml的配置方式可以通过

@Autowired
Map<String, ReferenceBean> references;

获取所有的client服务代理。

如果是使用@Reference好像就没有办法获取这些ReferenceBean了。

AnnotationBean这个类里面把ReferenceBean相关的属性使用了private,导致无法获取这些实例

private final ConcurrentMap<String, ReferenceBean<?>> referenceConfigs = new ConcurrentHashMap<String, ReferenceBean<?>>();
zhuduan commented 7 years ago

从context里面获取到保存所有Bean的Map,然后便利所有Bean中的所有方法。 如果方法的Annotation适配为@Reference的类型,则将该Bean记录下来 Method[] methods = UsingAnno.class.getMethods(); Annotation[] anno = method.getAnnotations();

不过效率比较低