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


Java ReferenceBean类代码示例

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


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

示例1: init

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
public void init() {
 //对标签中名字为application的进行解析,这里dubbo使用了统一的DubboBeanDefinitionParser进行解析。
    //DubboBeanDefinitionParser实现了BeanDefinitionParser接口,实现parse方法对标签进行解析。
    //将解析之后的标签变成Spring中的一个Bean对象。
    //application对应一个ApplicationConfig。
    //在执行完init方法之后,spring会得到所有的下面这个10个handler
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:18,代码来源:DubboNamespaceHandler.java

示例2: refer

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
/** 获取Dubbo服务 */
public static Object refer(ApplicationContext applicationContext, String interfaceName) {
    String key = "/" + interfaceName + ":";
    ReferenceBean<?> referenceConfig = referenceConfigs.get(key);
    if (referenceConfig == null) {
        referenceConfig = new ReferenceBean<Object>();
        referenceConfig.setInterface(interfaceName);
        if (applicationContext != null) {
            referenceConfig.setApplicationContext(applicationContext);
            try {
                referenceConfig.afterPropertiesSet();
            } catch (Exception e) {
                throw new IllegalStateException(e.getMessage(), e);
            }
        }
        referenceConfigs.putIfAbsent(key, referenceConfig);
        referenceConfig = referenceConfigs.get(key);
    }
    return referenceConfig.get();
}
 
开发者ID:guokezheng,项目名称:automat,代码行数:21,代码来源:DubboUtil.java

示例3: postProcessBeforeInitialization

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
@Override
 public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
     Class clazz = bean.getClass();
     if (ReferenceBean.class.isAssignableFrom(clazz)) {
         ReferenceBean referenceBean = (ReferenceBean) bean;
         referenceBean.setFilter("litxFilter");
         Class targetClass = referenceBean.getObjectType();
         registerDefinationList(targetClass);
     }
     if(RollbackInvokeHook.class.isAssignableFrom(clazz)){
     	try {
     		log.info(" [LITX] 初始化rollbackInvokeHook:"+clazz.getName());
	DefinitionManager.setRollbackInvokeHook((RollbackInvokeHook)clazz.newInstance());
} catch (InstantiationException | IllegalAccessException e) {
	log.error(" [LITX] 初始化回滚HOOK实现时出错",e);
}
     }
     return bean;
 }
 
开发者ID:thebeastshop,项目名称:litx,代码行数:20,代码来源:LitxDubboDefinationScanner.java

示例4: destroy

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
@Override
public void destroy() throws Exception {

    for (ReferenceBean referenceBean : referenceBeansCache.values()) {
        if (logger.isInfoEnabled()) {
            logger.info(referenceBean + " was destroying!");
        }
        referenceBean.destroy();
    }

    injectionMetadataCache.clear();
    referenceBeansCache.clear();

    if (logger.isInfoEnabled()) {
        logger.info(getClass() + " was destroying!");
    }

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

示例5: init

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
public void init() {
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:13,代码来源:DubboNamespaceHandler.java

示例6: configAndBuild

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的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

示例7: init

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
public void init() {
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
    registerBeanDefinitionParser("mockSystemUrl", new DubboBeanDefinitionParser(MockSystemUrlConfig.class, true));
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:14,代码来源:DubboNamespaceHandler.java

示例8: init

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
public void init() {
 registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
        // 注意这里是<dubbo:annotation package="com.package.to.be.scanned" />的解析
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
开发者ID:yuexiahandao,项目名称:DubboCode,代码行数:14,代码来源:DubboNamespaceHandler.java

示例9: init

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
public void init() {
    registerBeanDefinitionParser("application", new DubboBeanDefinitionParser(ApplicationConfig.class, true));
    registerBeanDefinitionParser("module", new DubboBeanDefinitionParser(ModuleConfig.class, true));
    registerBeanDefinitionParser("registry", new DubboBeanDefinitionParser(RegistryConfig.class, true));
    registerBeanDefinitionParser("monitor", new DubboBeanDefinitionParser(MonitorConfig.class, true));
    registerBeanDefinitionParser("provider", new DubboBeanDefinitionParser(ProviderConfig.class, true));
    registerBeanDefinitionParser("consumer", new DubboBeanDefinitionParser(ConsumerConfig.class, true));
    registerBeanDefinitionParser("protocol", new DubboBeanDefinitionParser(ProtocolConfig.class, true));
    registerBeanDefinitionParser("service", new DubboBeanDefinitionParser(ServiceBean.class, true));
    registerBeanDefinitionParser("reference", new DubboBeanDefinitionParser(ReferenceBean.class, false));
    registerBeanDefinitionParser("annotation", new DubboBeanDefinitionParser(AnnotationBean.class, true));
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:13,代码来源:DubboNamespaceHandler.java

示例10: buildReferenceBean

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
private Object buildReferenceBean(Reference reference, Class<?> referenceClass) throws Exception {

        String referenceBeanCacheKey = generateReferenceBeanCacheKey(reference, referenceClass);

        ReferenceBean<?> referenceBean = referenceBeansCache.get(referenceBeanCacheKey);

        if (referenceBean == null) {

            ReferenceBeanBuilder beanBuilder = ReferenceBeanBuilder
                    .create(reference, classLoader, applicationContext)
                    .interfaceClass(referenceClass);

            referenceBean = beanBuilder.build();

            referenceBeansCache.putIfAbsent(referenceBeanCacheKey, referenceBean);

        }


        return referenceBean.get();
    }
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:22,代码来源:ReferenceAnnotationBeanPostProcessor.java

示例11: doBuild

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
@Override
protected ReferenceBean doBuild() {
    return new ReferenceBean<Object>(annotation);
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:5,代码来源:ReferenceBeanBuilder.java

示例12: preConfigureBean

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
@Override
protected void preConfigureBean(Reference annotation, ReferenceBean bean) {
    Assert.notNull(interfaceClass, "The interface class must set first!");
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:5,代码来源:ReferenceBeanBuilder.java

示例13: configureInterface

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

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

示例14: configureConsumerConfig

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
private void configureConsumerConfig(Reference reference, ReferenceBean<?> referenceBean) {

        String consumerBeanName = reference.consumer();

        ConsumerConfig consumerConfig = getOptionalBean(applicationContext, consumerBeanName, ConsumerConfig.class);

        referenceBean.setConsumer(consumerConfig);

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

示例15: postConfigureBean

import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
@Override
protected void postConfigureBean(Reference annotation, ReferenceBean bean) throws Exception {

    bean.setApplicationContext(applicationContext);

    configureInterface(annotation, bean);

    configureConsumerConfig(annotation, bean);

    bean.afterPropertiesSet();

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


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