Search in sources :

Example 6 with ServiceBean

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();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ServiceBean(org.apache.dubbo.config.spring.ServiceBean) DemoServiceImpl(org.apache.dubbo.config.spring.impl.DemoServiceImpl) Test(org.junit.jupiter.api.Test) ConfigTest(org.apache.dubbo.config.spring.ConfigTest)

Example 7 with ServiceBean

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());
}
Also used : ServiceBean(org.apache.dubbo.config.spring.ServiceBean) Test(org.junit.jupiter.api.Test)

Example 8 with ServiceBean

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());
}
Also used : ServiceBean(org.apache.dubbo.config.spring.ServiceBean) Test(org.junit.jupiter.api.Test)

Example 9 with ServiceBean

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;
}
Also used : ReferenceAnnotationBeanPostProcessor(org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor) ServiceBean(org.apache.dubbo.config.spring.ServiceBean) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap)

Example 10 with ServiceBean

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;
}
Also used : ReferenceAnnotationBeanPostProcessor(org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor) ServiceBean(org.apache.dubbo.config.spring.ServiceBean) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ServiceBean (org.apache.dubbo.config.spring.ServiceBean)10 Test (org.junit.jupiter.api.Test)5 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 ProtocolConfig (org.apache.dubbo.config.ProtocolConfig)2 ConfigTest (org.apache.dubbo.config.spring.ConfigTest)2 ReferenceAnnotationBeanPostProcessor (org.apache.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2 Method (java.lang.reflect.Method)1 HashSet (java.util.HashSet)1 ConsumerConfig (org.apache.dubbo.config.ConsumerConfig)1 RegistryConfig (org.apache.dubbo.config.RegistryConfig)1 ReferenceBean (org.apache.dubbo.config.spring.ReferenceBean)1 DemoServiceImpl (org.apache.dubbo.config.spring.impl.DemoServiceImpl)1 PropertyValue (org.springframework.beans.PropertyValue)1 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)1 BeanDefinitionHolder (org.springframework.beans.factory.config.BeanDefinitionHolder)1 RuntimeBeanReference (org.springframework.beans.factory.config.RuntimeBeanReference)1 TypedStringValue (org.springframework.beans.factory.config.TypedStringValue)1