Java Code Examples for com.alibaba.dubbo.config.annotation.Service#interfaceName()
The following examples show how to use
com.alibaba.dubbo.config.annotation.Service#interfaceName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationUtils.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
public static String resolveInterfaceName(Service service, Class<?> defaultInterfaceClass) throws IllegalStateException { String interfaceName; if (StringUtils.hasText(service.interfaceName())) { interfaceName = service.interfaceName(); } else if (!void.class.equals(service.interfaceClass())) { interfaceName = service.interfaceClass().getName(); } else if (defaultInterfaceClass.isInterface()) { interfaceName = defaultInterfaceClass.getName(); } else { throw new IllegalStateException( "The @Service undefined interfaceClass or interfaceName, and the type " + defaultInterfaceClass.getName() + " is not a interface."); } return interfaceName; }
Example 2
Source File: AnnotationBean.java From spring-boot-starter-dubbo with Apache License 2.0 | 6 votes |
private Class<?> resolveServiceInterfaceClass(Class<?> annotatedServiceBeanClass, Service service) { Class<?> interfaceClass = service.interfaceClass(); if (void.class.equals(interfaceClass)) { interfaceClass = null; String interfaceClassName = service.interfaceName(); if (StringUtils.hasText(interfaceClassName)) { if (ClassUtils.isPresent(interfaceClassName, classLoader)) { interfaceClass = resolveClassName(interfaceClassName, classLoader); } } } if(interfaceClass==null){ return null; } Assert.isTrue(interfaceClass.isInterface(), "The type that was annotated @Service is not an interface!"); return interfaceClass; }
Example 3
Source File: DubboProviderAutoConfiguration.java From dubbo-spring-boot-starter with Apache License 2.0 | 5 votes |
private void initProviderBean(String beanName, Object bean) throws Exception { Service service = this.applicationContext.findAnnotationOnBean(beanName, Service.class); ServiceBean<Object> serviceConfig = new ServiceBean<Object>(service); if ((service.interfaceClass() == null || service.interfaceClass() == void.class) && (service.interfaceName() == null || "".equals(service.interfaceName()))) { Class<?>[] interfaces = bean.getClass().getInterfaces(); if (interfaces.length > 0) { serviceConfig.setInterface(interfaces[0]); } } Environment environment = this.applicationContext.getEnvironment(); String application = service.application(); serviceConfig.setApplication(this.parseApplication(application, this.properties, environment, beanName, "application", application)); String module = service.module(); serviceConfig.setModule( this.parseModule(module, this.properties, environment, beanName, "module", module)); String[] registries = service.registry(); serviceConfig.setRegistries( this.parseRegistries(registries, this.properties, environment, beanName, "registry")); String[] protocols = service.protocol(); serviceConfig.setProtocols( this.parseProtocols(protocols, this.properties, environment, beanName, "registry")); String monitor = service.monitor(); serviceConfig.setMonitor( this.parseMonitor(monitor, this.properties, environment, beanName, "monitor", monitor)); String provider = service.provider(); serviceConfig.setProvider( this.parseProvider(provider, this.properties, environment, beanName, "provider", provider)); serviceConfig.setApplicationContext(this.applicationContext); serviceConfig.afterPropertiesSet(); serviceConfig.setRef(bean); serviceConfig.export(); }
Example 4
Source File: ServiceAnnotationBeanPostProcessor.java From dubbo-2.6.5 with Apache License 2.0 | 3 votes |
private Class<?> resolveServiceInterfaceClass(Class<?> annotatedServiceBeanClass, Service service) { Class<?> interfaceClass = service.interfaceClass(); if (void.class.equals(interfaceClass)) { interfaceClass = null; String interfaceClassName = service.interfaceName(); if (StringUtils.hasText(interfaceClassName)) { if (ClassUtils.isPresent(interfaceClassName, classLoader)) { interfaceClass = resolveClassName(interfaceClassName, classLoader); } } } if (interfaceClass == null) { Class<?>[] allInterfaces = annotatedServiceBeanClass.getInterfaces(); if (allInterfaces.length > 0) { interfaceClass = allInterfaces[0]; } } Assert.notNull(interfaceClass, "@Service interfaceClass() or interfaceName() or interface class must be present!"); Assert.isTrue(interfaceClass.isInterface(), "The type that was annotated @Service is not an interface!"); return interfaceClass; }
Example 5
Source File: FeignClientToDubboProviderBeanPostProcessor.java From spring-cloud-alibaba-dubbo with Apache License 2.0 | 3 votes |
private Class<?> resolveServiceInterfaceClass(Class<?> annotatedServiceBeanClass, Service service) { Class<?> interfaceClass = service.interfaceClass(); if (void.class.equals(interfaceClass)) { interfaceClass = null; String interfaceClassName = service.interfaceName(); if (StringUtils.hasText(interfaceClassName)) { if (ClassUtils.isPresent(interfaceClassName, classLoader)) { interfaceClass = resolveClassName(interfaceClassName, classLoader); } } } if (interfaceClass == null) { Class<?>[] allInterfaces = annotatedServiceBeanClass.getInterfaces(); if (allInterfaces.length > 0) { interfaceClass = allInterfaces[0]; } } Assert.notNull(interfaceClass, "@Service interfaceClass() or interfaceName() or interface class must be present!"); Assert.isTrue(interfaceClass.isInterface(), "The type that was annotated @Service is not an interface!"); return interfaceClass; }
Example 6
Source File: FeignClientToDubboProviderBeanPostProcessor.java From spring-cloud-dubbo with Apache License 2.0 | 3 votes |
private Class<?> resolveServiceInterfaceClass(Class<?> annotatedServiceBeanClass, Service service) { Class<?> interfaceClass = service.interfaceClass(); if (void.class.equals(interfaceClass)) { interfaceClass = null; String interfaceClassName = service.interfaceName(); if (StringUtils.hasText(interfaceClassName)) { if (ClassUtils.isPresent(interfaceClassName, classLoader)) { interfaceClass = resolveClassName(interfaceClassName, classLoader); } } } if (interfaceClass == null) { Class<?>[] allInterfaces = annotatedServiceBeanClass.getInterfaces(); if (allInterfaces.length > 0) { interfaceClass = allInterfaces[0]; } } Assert.notNull(interfaceClass, "@Service interfaceClass() or interfaceName() or interface class must be present!"); Assert.isTrue(interfaceClass.isInterface(), "The type that was annotated @Service is not an interface!"); return interfaceClass; }