use of com.alibaba.dubbo.config.spring.ReferenceBean in project dubbo by alibaba.
the class ReferenceAnnotationBeanPostProcessor method destroy.
@Override
public void destroy() throws Exception {
for (ReferenceBean referenceBean : referenceBeansCache.values()) {
if (logger.isInfoEnabled()) {
logger.info(referenceBean + " was destroying!");
}
referenceBean.destroy();
}
injectionMetadataCache.clear();
referenceBeansCache.clear();
if (logger.isInfoEnabled()) {
logger.info(getClass() + " was destroying!");
}
}
use of com.alibaba.dubbo.config.spring.ReferenceBean in project dubbo by alibaba.
the class ReferenceAnnotationBeanPostProcessorTest method testGetReferenceBeans.
/**
* Test on {@link ReferenceAnnotationBeanPostProcessor#getReferenceBeans()}
*/
@Test
public void testGetReferenceBeans() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(TestBean.class);
ReferenceAnnotationBeanPostProcessor beanPostProcessor = context.getBean(BEAN_NAME, ReferenceAnnotationBeanPostProcessor.class);
Collection<ReferenceBean<?>> referenceBeans = beanPostProcessor.getReferenceBeans();
Assert.assertEquals(1, referenceBeans.size());
ReferenceBean<?> referenceBean = referenceBeans.iterator().next();
TestBean testBean = context.getBean(TestBean.class);
Assert.assertEquals(referenceBean.get(), testBean.getDemoServiceFromAncestor());
Assert.assertEquals(referenceBean.get(), testBean.getDemoServiceFromParent());
Assert.assertEquals(referenceBean.get(), testBean.getDemoService());
}
use of com.alibaba.dubbo.config.spring.ReferenceBean in project incubator-dubbo-spring-boot-project by apache.
the class DubboMvcEndpoint method resolveInjectedElementReferenceBeanMap.
/**
* Resolves the {@link Collection} of {@link InjectionMetadata.InjectedElement} that were annotated by {@link Reference}
* from all Spring Beans.
*
* @return non-null {@link Collection}
* TODO Reactors ReferenceAnnotationBeanPostProcessor to expose those info
*/
private Map<InjectionMetadata.InjectedElement, ReferenceBean<?>> resolveInjectedElementReferenceBeanMap() {
Map<InjectionMetadata.InjectedElement, ReferenceBean<?>> injectedElementReferenceBeanMap = new LinkedHashMap<>();
final ReferenceAnnotationBeanPostProcessor processor = getReferenceAnnotationBeanPostProcessor();
ConcurrentMap<String, InjectionMetadata> injectionMetadataCache = getFieldValue(processor, "injectionMetadataCache", ConcurrentMap.class);
ConcurrentMap<String, ReferenceBean<?>> referenceBeansCache = getFieldValue(processor, "referenceBeansCache", ConcurrentMap.class);
for (InjectionMetadata metadata : injectionMetadataCache.values()) {
Set<InjectionMetadata.InjectedElement> checkedElements = getFieldValue(metadata, "checkedElements", Set.class);
Collection<InjectionMetadata.InjectedElement> injectedElements = getFieldValue(metadata, "injectedElements", Collection.class);
Collection<InjectionMetadata.InjectedElement> actualInjectedElements = checkedElements != null ? checkedElements : injectedElements;
for (InjectionMetadata.InjectedElement injectedElement : actualInjectedElements) {
ReferenceBean<?> referenceBean = resolveReferenceBean(injectedElement, referenceBeansCache);
injectedElementReferenceBeanMap.put(injectedElement, referenceBean);
}
}
return injectedElementReferenceBeanMap;
}
Aggregations