当前位置: 首页>>代码示例>>Java>>正文


Java Reference类代码示例

本文整理汇总了Java中com.alibaba.dubbo.config.annotation.Reference的典型用法代码示例。如果您正苦于以下问题:Java Reference类的具体用法?Java Reference怎么用?Java Reference使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Reference类属于com.alibaba.dubbo.config.annotation包,在下文中一共展示了Reference类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveInterfaceName

import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
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;

}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:20,代码来源:ReferenceAnnotationBeanPostProcessor.java

示例2: configAndBuild

import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
public ReferenceBean configAndBuild(Reference reference, Class<?> interfaceClass) throws Exception {
    ReferenceBean referenceBean = new ReferenceBean(reference);

    referenceBean.setApplication(findBean(reference.application(), ApplicationConfig.class));
    referenceBean.setRegistries(findBean(reference.registry(), RegistryConfig.class));
    referenceBean.setModule(findBean(reference.module(), ModuleConfig.class));
    referenceBean.setApplicationContext(applicationContext);
    referenceBean.setInterface(interfaceClass);
    referenceBean.afterPropertiesSet();

    return referenceBean;
}
 
开发者ID:justice-code,项目名称:dubbo-spring-boot-autoconfig,代码行数:13,代码来源:DubboReferenceInjector.java

示例3: inject

import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
@Override
protected void inject(final MethodInvocation invocation, final Method method, final Class<?> returnType) throws Throwable {
    final Reference reference = method.getAnnotation(Reference.class);
    final ReferenceConfig<?> refer = new ReferenceConfig<>(reference);
    refer.setCheck(reference.check());
    refer.setInterface(returnType);
    final Object newInstance = ReferenceConfigCache.getCache().get(refer);
    setInstance(invocation.getThis(), method, returnType, newInstance);
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:10,代码来源:DubboReferenceInterceptor.java

示例4: injectMembers

import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
@Override
public void injectMembers(final T instance) {
    try {
        final Reference reference = field.getAnnotation(Reference.class);
        final ReferenceConfig<?> refer = new ReferenceConfig<>(reference);
        refer.setCheck(reference.check());
        refer.setInterface(field.getType());
        final Object newInstance = ReferenceConfigCache.getCache().get(refer);
        field.set(instance, newInstance);
    } catch (final IllegalAccessException e) {
        throw (Error) new IllegalAccessError(e.getMessage()).initCause(e);
    }
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:14,代码来源:DubboReferenceInjector.java

示例5: findFieldReferenceMetadata

import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
/**
 * Finds {@link InjectionMetadata.InjectedElement} Metadata from annotated {@link Reference @Reference} fields
 *
 * @param beanClass The {@link Class} of Bean
 * @return non-null {@link List}
 */
private List<InjectionMetadata.InjectedElement> findFieldReferenceMetadata(final Class<?> beanClass) {

    final List<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();

    ReflectionUtils.doWithFields(beanClass, new ReflectionUtils.FieldCallback() {
        @Override
        public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {

            Reference reference = findReferenceAnnotation(field);

            if (reference != null) {

                if (Modifier.isStatic(field.getModifiers())) {
                    if (logger.isWarnEnabled()) {
                        logger.warn("@Reference annotation is not supported on static fields: " + field);
                    }
                    return;
                }

                elements.add(new ReferenceFieldElement(field, reference));
            }

        }
    });

    return elements;

}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:35,代码来源:ReferenceAnnotationBeanPostProcessor.java

示例6: findMethodReferenceMetadata

import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
/**
 * Finds {@link InjectionMetadata.InjectedElement} Metadata from annotated {@link Reference @Reference} methods
 *
 * @param beanClass The {@link Class} of Bean
 * @return non-null {@link List}
 */
private List<InjectionMetadata.InjectedElement> findMethodReferenceMetadata(final Class<?> beanClass) {

    final List<InjectionMetadata.InjectedElement> elements = new LinkedList<InjectionMetadata.InjectedElement>();

    ReflectionUtils.doWithMethods(beanClass, new ReflectionUtils.MethodCallback() {
        @Override
        public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {

            Method bridgedMethod = BridgeMethodResolver.findBridgedMethod(method);

            if (!BridgeMethodResolver.isVisibilityBridgeMethodPair(method, bridgedMethod)) {
                return;
            }

            Reference reference = findReferenceAnnotation(bridgedMethod);

            if (reference != null && method.equals(ClassUtils.getMostSpecificMethod(method, beanClass))) {
                if (Modifier.isStatic(method.getModifiers())) {
                    if (logger.isWarnEnabled()) {
                        logger.warn("@Reference annotation is not supported on static methods: " + method);
                    }
                    return;
                }
                if (method.getParameterTypes().length == 0) {
                    if (logger.isWarnEnabled()) {
                        logger.warn("@Reference  annotation should only be used on methods with parameters: " +
                                method);
                    }
                }
                PropertyDescriptor pd = BeanUtils.findPropertyForMethod(bridgedMethod, beanClass);
                elements.add(new ReferenceMethodElement(method, pd, reference));
            }
        }
    });

    return elements;

}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:45,代码来源:ReferenceAnnotationBeanPostProcessor.java

示例7: ReferenceBean

import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
public ReferenceBean(Reference reference) {
    super(reference);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:4,代码来源:ReferenceBean.java

示例8: ReferenceConfig

import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
public ReferenceConfig(Reference reference) {
    appendAnnotation(Reference.class, reference);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:4,代码来源:ReferenceConfig.java

示例9: ReferenceInjectedElement

import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
protected ReferenceInjectedElement(Member member, PropertyDescriptor pd, Reference reference) {
    super(member, pd);
    this.reference = reference;
}
 
开发者ID:justice-code,项目名称:dubbo-spring-boot-autoconfig,代码行数:5,代码来源:DubboReferenceInjector.java

示例10: configure

import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
@Override
public void configure(final Binder binder) {
    binder.bindInterceptor(Matchers.any(), Matchers.annotatedWith(Reference.class), new DubboReferenceInterceptor());
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:5,代码来源:DubboReferenceModule.java

示例11: getHelloWorldService

import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
@Inject
@Reference(check = false, url = "dubbo://" + SERVER + "/org.nanoframework.extension.dubbo.service.HelloWorldService")
public HelloWorldService getHelloWorldService() {
    return helloWorldService;
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:6,代码来源:HelloWorldProxy.java

示例12:

import com.alibaba.dubbo.config.annotation.Reference; //导入依赖的package包/类
@Inject
@Reference(check = false, url = "dubbo://" + SERVER + "/org.nanoframework.extension.dubbo.service.HelloWorld2Service")
public HelloWorld2Service getHelloWorld2Service() {
    return helloWorld2Service;
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:6,代码来源:HelloWorldProxy.java


注:本文中的com.alibaba.dubbo.config.annotation.Reference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。