use of org.apache.dubbo.config.annotation.Service in project dubbo by alibaba.
the class AnnotationUtilsTest method assertADeclaredAnnotations.
private void assertADeclaredAnnotations(List<Annotation> annotations, int offset) {
int size = 3 + offset;
assertEquals(size, annotations.size());
Service service = (Service) annotations.get(offset++);
assertEquals("java.lang.CharSequence", service.interfaceName());
assertEquals(CharSequence.class, service.interfaceClass());
com.alibaba.dubbo.config.annotation.Service s = (com.alibaba.dubbo.config.annotation.Service) annotations.get(offset++);
assertEquals("java.lang.CharSequence", service.interfaceName());
assertEquals(CharSequence.class, service.interfaceClass());
Adaptive adaptive = (Adaptive) annotations.get(offset++);
assertArrayEquals(new String[] { "a", "b", "c" }, adaptive.value());
}
use of org.apache.dubbo.config.annotation.Service in project dubbo by alibaba.
the class ServiceBeanNameBuilderTest method testServiceAnnotation.
@Test
public void testServiceAnnotation() {
Service service = AnnotationUtils.getAnnotation(ServiceBeanNameBuilderTest.class, Service.class);
ServiceBeanNameBuilder builder = ServiceBeanNameBuilder.create(service, INTERFACE_CLASS, environment);
Assertions.assertEquals("ServiceBean:org.apache.dubbo.config.spring.api.DemoService:1.0.0:DUBBO", builder.build());
Assertions.assertEquals("ServiceBean:org.apache.dubbo.config.spring.api.DemoService:1.0.0:DUBBO", builder.build());
}
use of org.apache.dubbo.config.annotation.Service in project dubbo by alibaba.
the class MergedAnnotationTest method testMergedService.
@Test
public void testMergedService() {
Service service1 = AnnotatedElementUtils.getMergedAnnotation(DemoServiceImpl1.class, Service.class);
Assertions.assertEquals("dubbo", service1.group());
Assertions.assertEquals("1.0.0", service1.version());
Service service2 = AnnotatedElementUtils.getMergedAnnotation(DemoServiceImpl2.class, Service.class);
Assertions.assertEquals("group", service2.group());
Assertions.assertEquals("2.0", service2.version());
}
use of org.apache.dubbo.config.annotation.Service in project dubbo by alibaba.
the class ReferenceAnnotationBeanPostProcessor method doGetInjectedBean.
@Override
protected Object doGetInjectedBean(AnnotationAttributes attributes, Object bean, String beanName, Class<?> injectedType, InjectionMetadata.InjectedElement injectedElement) throws Exception {
/**
* The name of bean that annotated Dubbo's {@link Service @Service} in local Spring {@link ApplicationContext}
*/
String referencedBeanName = buildReferencedBeanName(attributes, injectedType);
/**
* The name of bean that is declared by {@link Reference @Reference} annotation injection
*/
String referenceBeanName = getReferenceBeanName(attributes, injectedType);
referencedBeanNameIdx.computeIfAbsent(referencedBeanName, k -> new TreeSet<String>()).add(referenceBeanName);
ReferenceBean referenceBean = buildReferenceBeanIfAbsent(referenceBeanName, attributes, injectedType);
boolean localServiceBean = isLocalServiceBean(referencedBeanName, referenceBean, attributes);
prepareReferenceBean(referencedBeanName, referenceBean, localServiceBean);
registerReferenceBean(referencedBeanName, referenceBean, localServiceBean, referenceBeanName);
cacheInjectedReferenceBean(referenceBean, injectedElement);
return getBeanFactory().applyBeanPostProcessorsAfterInitialization(referenceBean.get(), referenceBeanName);
}
use of org.apache.dubbo.config.annotation.Service in project dubbo by alibaba.
the class ServiceBeanTest method testGetService.
@Test
public void testGetService() {
TestService service = mock(TestService.class);
ServiceBean serviceBean = new ServiceBean(service);
Service beanService = serviceBean.getService();
MatcherAssert.assertThat(beanService, not(nullValue()));
}
Aggregations