Java Code Examples for com.alibaba.dubbo.config.annotation.Reference#interfaceName()

The following examples show how to use com.alibaba.dubbo.config.annotation.Reference#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 vote down vote up
public static String resolveInterfaceName(Reference reference, Class<?> defaultInterfaceClass)
        throws IllegalStateException {

    String interfaceName;
    if (!"".equals(reference.interfaceName())) {
        interfaceName = reference.interfaceName();
    } else if (!void.class.equals(reference.interfaceClass())) {
        interfaceName = reference.interfaceClass().getName();
    } else if (defaultInterfaceClass.isInterface()) {
        interfaceName = defaultInterfaceClass.getName();
    } else {
        throw new IllegalStateException(
                "The @Reference undefined interfaceClass or interfaceName, and the type "
                        + defaultInterfaceClass.getName() + " is not a interface.");
    }

    return interfaceName;

}
 
Example 2
Source File: InjectAnnotationBeanPostProcessor.java    From spring-boot-starter-dubbo with Apache License 2.0 6 votes vote down vote up
private static String resolveInterfaceName(Reference reference, Class<?> beanClass)
        throws IllegalStateException {

    String interfaceName;
    if (!"".equals(reference.interfaceName())) {
        interfaceName = reference.interfaceName();
    } else if (!void.class.equals(reference.interfaceClass())) {
        interfaceName = reference.interfaceClass().getName();
    } else if (beanClass.isInterface()) {
        interfaceName = beanClass.getName();
    } else {
        throw new IllegalStateException(
                "The @Reference undefined interfaceClass or interfaceName, and the property type "
                        + beanClass.getName() + " is not a interface.");
    }

    return interfaceName;

}
 
Example 3
Source File: DubboConsumerAutoConfiguration.java    From dubbo-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
/**
 * init consumer bean
 *
 * @param interfaceClazz interfaceClazz
 * @param reference reference
 * @return ReferenceBean<T>
 * @throws BeansException BeansException
 */
private <T> ReferenceBean<T> getConsumerBean(String beanName, Field field, Reference reference)
    throws BeansException {
  ReferenceBean<T> referenceBean = new ReferenceBean<T>(reference);
  if ((reference.interfaceClass() == null || reference.interfaceClass() == void.class)
      && (reference.interfaceName() == null || "".equals(reference.interfaceName()))) {
    referenceBean.setInterface(field.getType());
  }

  Environment environment = this.applicationContext.getEnvironment();
  String application = reference.application();
  referenceBean.setApplication(this.parseApplication(application, this.properties, environment,
      beanName, field.getName(), "application", application));
  String module = reference.module();
  referenceBean.setModule(this.parseModule(module, this.properties, environment, beanName,
      field.getName(), "module", module));
  String[] registries = reference.registry();
  referenceBean.setRegistries(this.parseRegistries(registries, this.properties, environment,
      beanName, field.getName(), "registry"));
  String monitor = reference.monitor();
  referenceBean.setMonitor(this.parseMonitor(monitor, this.properties, environment, beanName,
      field.getName(), "monitor", monitor));
  String consumer = reference.consumer();
  referenceBean.setConsumer(this.parseConsumer(consumer, this.properties, environment, beanName,
      field.getName(), "consumer", consumer));

  referenceBean.setApplicationContext(DubboConsumerAutoConfiguration.this.applicationContext);
  return referenceBean;
}
 
Example 4
Source File: ReferenceBeanBuilder.java    From dubbo-2.6.5 with Apache License 2.0 3 votes vote down vote up
private void configureInterface(Reference reference, ReferenceBean referenceBean) {

        Class<?> interfaceClass = reference.interfaceClass();

        if (void.class.equals(interfaceClass)) {

            interfaceClass = null;

            String interfaceClassName = reference.interfaceName();

            if (StringUtils.hasText(interfaceClassName)) {
                if (ClassUtils.isPresent(interfaceClassName, classLoader)) {
                    interfaceClass = ClassUtils.resolveClassName(interfaceClassName, classLoader);
                }
            }

        }

        if (interfaceClass == null) {
            interfaceClass = this.interfaceClass;
        }

        Assert.isTrue(interfaceClass.isInterface(),
                "The class of field or method that was annotated @Reference is not an interface!");

        referenceBean.setInterface(interfaceClass);

    }