use of org.apache.dubbo.config.spring.ServiceBean in project dubbo by alibaba.
the class DubboNamespaceHandlerTest method testProperty.
@Test
public void testProperty() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/service-class.xml");
ctx.start();
ServiceBean serviceBean = ctx.getBean(ServiceBean.class);
String prefix = ((DemoServiceImpl) serviceBean.getRef()).getPrefix();
assertThat(prefix, is("welcome:"));
ctx.close();
}
use of org.apache.dubbo.config.spring.ServiceBean in project dubbo by alibaba.
the class ServiceAnnotationBeanPostProcessorTest method testMethodAnnotation.
@Test
public void testMethodAnnotation() {
Map<String, ServiceBean> serviceBeansMap = beanFactory.getBeansOfType(ServiceBean.class);
/**
* There are one {@link HelloService} and two {@link LazyInitHelloService} has 1
*/
Assertions.assertEquals(3, serviceBeansMap.size());
ServiceBean demoServiceBean = serviceBeansMap.get("ServiceBean:org.apache.dubbo.config.spring.api.DemoService:2.5.7");
Assertions.assertNotNull(demoServiceBean.getMethods());
}
use of org.apache.dubbo.config.spring.ServiceBean in project dubbo by alibaba.
the class ServiceClassPostProcessorTest method testMethodAnnotation.
@Test
public void testMethodAnnotation() {
Map<String, ServiceBean> serviceBeansMap = beanFactory.getBeansOfType(ServiceBean.class);
/**
* There are one {@link HelloService} and two {@link LazyInitHelloService} has 1
*/
Assertions.assertEquals(3, serviceBeansMap.size());
ServiceBean demoServiceBean = serviceBeansMap.get("ServiceBean:org.apache.dubbo.config.spring.api.DemoService:2.5.7");
Assertions.assertNotNull(demoServiceBean.getMethods());
}
use of org.apache.dubbo.config.spring.ServiceBean in project dubbo by alibaba.
the class DubboShutdownMetadata method shutdown.
public Map<String, Object> shutdown() throws Exception {
Map<String, Object> shutdownCountData = new LinkedHashMap<>();
// registries
int registriesCount = getRegistries().size();
// protocols
int protocolsCount = getProtocolConfigsBeanMap().size();
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);
return shutdownData;
}
use of org.apache.dubbo.config.spring.ServiceBean in project incubator-dubbo-spring-boot-project by apache.
the class DubboShutdownMetadata method shutdown.
public Map<String, Object> shutdown() throws Exception {
Map<String, Object> shutdownCountData = new LinkedHashMap<>();
// registries
int registriesCount = getRegistries().size();
// protocols
int protocolsCount = getProtocolConfigsBeanMap().size();
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);
return shutdownData;
}
Aggregations