本文整理汇总了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));
}
示例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();
}
示例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;
}
示例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!");
}
}
示例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));
}
示例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;
}
示例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));
}
示例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));
}
示例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));
}
示例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();
}
示例11: doBuild
import com.alibaba.dubbo.config.spring.ReferenceBean; //导入依赖的package包/类
@Override
protected ReferenceBean doBuild() {
return new ReferenceBean<Object>(annotation);
}
示例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!");
}
示例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);
}
示例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);
}
示例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();
}