use of com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor in project incubator-dubbo-spring-boot-project by apache.
the class DubboMvcEndpoint method shutdown.
@RequestMapping(value = DUBBO_SHUTDOWN_ENDPOINT_URI, method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public DeferredResult shutdown() throws Exception {
DeferredResult result = new DeferredResult();
Map<String, Object> shutdownCountData = new LinkedHashMap<>();
// registries
int registriesCount = getRegistries().size();
// protocols
int protocolsCount = getProtocolConfigsBeanMap().size();
ProtocolConfig.destroyAll();
shutdownCountData.put("registries", registriesCount);
shutdownCountData.put("protocols", protocolsCount);
// Service Beans
Map<String, ServiceBean> serviceBeansMap = getServiceBeansMap();
if (!serviceBeansMap.isEmpty()) {
for (ServiceBean serviceBean : serviceBeansMap.values()) {
serviceBean.destroy();
}
}
shutdownCountData.put("services", serviceBeansMap.size());
// Reference Beans
ReferenceAnnotationBeanPostProcessor beanPostProcessor = getReferenceAnnotationBeanPostProcessor();
int referencesCount = beanPostProcessor.getReferenceBeans().size();
beanPostProcessor.destroy();
shutdownCountData.put("references", referencesCount);
// Set Result to complete
Map<String, Object> shutdownData = new TreeMap<>();
shutdownData.put("shutdown.count", shutdownCountData);
result.setResult(shutdownData);
return result;
}
use of com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor 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