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


Java ReferenceConfig类代码示例

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


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

示例1: getCaller

import com.alibaba.dubbo.config.ReferenceConfig; //导入依赖的package包/类
private GenericService getCaller(String appId, String busCode,EasyTransRequest<?,?> request) {
	GenericService genericService = mapRef.get(getTargetKey(appId,busCode));
	if(genericService == null){
		
		List<Class<?>> typeArguments = ReflectUtil.getTypeArguments(EasyTransRequest.class, request.getClass());
		Class<?> executorCLass = typeArguments.get(1);
		RelativeInterface annotation = executorCLass.getAnnotation(RelativeInterface.class);
		Class<?> value = annotation.value();
		ReferenceConfig<GenericService> referenceConfig = new ReferenceConfig<GenericService>();
		referenceConfig.setInterface(value.getName()); // 弱类型接口名 
		referenceConfig.setVersion("1.0.0"); 
		referenceConfig.setGeneric(true); // 声明为泛化接口 
		referenceConfig.setApplication(new ApplicationConfig(applicationName));
		referenceConfig.setRegistry(new RegistryConfig(dubboZkUrl));
		referenceConfig.setGroup(appId + "-" + busCode);
		referenceConfig.setCheck(false);
		referenceConfig.setSticky(true);//设置粘滞连接以优化级联事务的级联提交性能
		genericService = referenceConfig.get();
		mapRef.put(getTargetKey(appId,busCode), genericService);
	}
	return genericService;
}
 
开发者ID:QNJR-GROUP,项目名称:EasyTransaction,代码行数:23,代码来源:DubboEasyTransRpcConsumerImpl.java

示例2: getProxy

import com.alibaba.dubbo.config.ReferenceConfig; //导入依赖的package包/类
public Object getProxy(String interfaceClass) {
    Set<Entry<Class<?>, Object>> entrySet = interfaceMapProxy.entrySet();
    for (Entry<Class<?>, Object> entry : entrySet) {
        if (entry.getKey().getName().equals(interfaceClass)) { return entry.getValue(); }
    }

    for (ServiceBean<?> service : services) {
        if (interfaceClass.equals(service.getInterfaceClass().getName())) {
            ReferenceConfig<Object> reference = new ReferenceConfig<Object>();
            reference.setApplication(service.getApplication());
            reference.setRegistry(service.getRegistry());
            reference.setRegistries(service.getRegistries());
            reference.setInterface(service.getInterfaceClass());
            reference.setVersion(service.getVersion());
            interfaceMapProxy.put(service.getInterfaceClass(), reference.get());
            return reference.get();
        }
    }
    return null;
}
 
开发者ID:Sayi,项目名称:swagger-dubbo,代码行数:21,代码来源:ReferenceManager.java

示例3: createClient

import com.alibaba.dubbo.config.ReferenceConfig; //导入依赖的package包/类
protected T createClient(Class<T> cls, String targetIP, int targetPort, int connectTimeout,int clientNums){
    ReferenceConfig<T> referenceConfig = new ReferenceConfig<T>();
    referenceConfig.setInterface(cls);
    StringBuilder url = new StringBuilder();
    url.append("dubbo://");
    url.append(targetIP);
    url.append(":");
    url.append(targetPort);
    url.append("/");
    url.append(cls.getName());
    referenceConfig.setUrl(url.toString());
    // hardcode
    referenceConfig.setConnections(clientNums);
    ApplicationConfig application = new ApplicationConfig();
    application.setName("dubbo_consumer");
    referenceConfig.setApplication(application);
    referenceConfig.setTimeout(connectTimeout);
    return referenceConfig.get();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:20,代码来源:ServiceFactory.java

示例4: testSystemPropertyOverrideReferenceConfig

import com.alibaba.dubbo.config.ReferenceConfig; //导入依赖的package包/类
@Test
public void testSystemPropertyOverrideReferenceConfig() throws Exception {
    System.setProperty("dubbo.reference.retries", "5");

    try {
        ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
        service.setInterface(DemoService.class);
        service.setRef(new DemoServiceImpl());
        service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
        ProtocolConfig protocolConfig = new ProtocolConfig("injvm");
        service.setProtocol(protocolConfig);
        service.export();

        ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
        reference.setInterface(DemoService.class);
        reference.setInjvm(true);
        reference.setRetries(2);
        reference.get();
        assertEquals(Integer.valueOf(5), reference.getRetries());
    } finally {
        System.setProperty("dubbo.reference.retries", "");
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:24,代码来源:ConfigTest.java

示例5: generateKey

import com.alibaba.dubbo.config.ReferenceConfig; //导入依赖的package包/类
public String generateKey(ReferenceConfig<?> referenceConfig) {
    String iName = referenceConfig.getInterface();
    if(StringUtils.isBlank(iName)) {
        Class<?> clazz = referenceConfig.getInterfaceClass();
        iName = clazz.getName();
    }
    if(StringUtils.isBlank(iName)) {
        throw new IllegalArgumentException("No interface info in ReferenceConfig" + referenceConfig);
    }

    StringBuilder ret = new StringBuilder();
    if(! StringUtils.isBlank(referenceConfig.getGroup())) {
        ret.append(referenceConfig.getGroup()).append("/");
    }
    ret.append(iName);
    if(! StringUtils.isBlank(referenceConfig.getVersion())) {
        ret.append(":").append(referenceConfig.getVersion());
    }
    return ret.toString();
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:21,代码来源:ReferenceConfigCache.java

示例6: createClient

import com.alibaba.dubbo.config.ReferenceConfig; //导入依赖的package包/类
protected T createClient(Class<T> cls, String targetIP, int targetPort, int connectTimeout,int clientNums, String protocol, String serialization){
    ReferenceConfig<T> referenceConfig = new ReferenceConfig<T>();
    referenceConfig.setInterface(cls);
    StringBuilder url = new StringBuilder();
    url.append(protocol);
    url.append("://");
    url.append(targetIP);
    url.append(":");
    url.append(targetPort);
    url.append("/");
    url.append(cls.getName());
    url.append("?optimizer=com.alibaba.dubbo.rpc.benchmark.SerializationOptimizerImpl");
    if (!StringUtils.isEmpty(serialization)) {
        url.append("&serialization=");
        url.append(serialization);
    }
    referenceConfig.setUrl(url.toString());
    // hardcode
    referenceConfig.setConnections(clientNums);
    ApplicationConfig application = new ApplicationConfig();
    application.setName("dubbo_consumer");
    referenceConfig.setApplication(application);
    referenceConfig.setTimeout(connectTimeout);
    return referenceConfig.get();
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:26,代码来源:ServiceFactory.java

示例7: getService

import com.alibaba.dubbo.config.ReferenceConfig; //导入依赖的package包/类
public static <S>  S getService(Class<S> c){
	ApplicationConfig application = new ApplicationConfig();
	application.setName("beast-litx");
	 
	RegistryConfig registry = new RegistryConfig();
	registry.setAddress("zookeeper://114.55.174.189:2181");
	registry.setGroup("dubbo-zhang");

	ReferenceConfig<S> reference = new ReferenceConfig<S>(); 
	reference.setApplication(application);
	reference.setRegistry(registry); 
	reference.setInterface(c);
	reference.setTimeout(30000);
	reference.setRetries(0);
	
	S service = reference.get();
	return service;
}
 
开发者ID:thebeastshop,项目名称:litx,代码行数:19,代码来源:ServiceUtils.java

示例8: main

import com.alibaba.dubbo.config.ReferenceConfig; //导入依赖的package包/类
public static void main(String[] args) {
    ApplicationConfig application = new ApplicationConfig();
    application.setName("demo-consumer");

    RegistryConfig registry = new RegistryConfig();
    registry.setAddress("zookeeper://127.0.0.1:2181");

    ReferenceConfig<DemoService> reference = new ReferenceConfig<>();
    reference.setApplication(application);
    reference.setRegistry(registry);
    reference.setInterface(DemoService.class);
    reference.setVersion("1.0.0");

    DemoService demoService = reference.get();
    System.out.println(demoService.sayHello("hongxi"));
}
 
开发者ID:javahongxi,项目名称:whatsmars,代码行数:17,代码来源:Consumer.java

示例9: generateKey

import com.alibaba.dubbo.config.ReferenceConfig; //导入依赖的package包/类
public String generateKey(ReferenceConfig<?> referenceConfig) {
    String iName = referenceConfig.getInterface();
    if (StringUtils.isBlank(iName)) {
        Class<?> clazz = referenceConfig.getInterfaceClass();
        iName = clazz.getName();
    }
    if (StringUtils.isBlank(iName)) {
        throw new IllegalArgumentException("No interface info in ReferenceConfig" + referenceConfig);
    }

    StringBuilder ret = new StringBuilder();
    if (!StringUtils.isBlank(referenceConfig.getGroup())) {
        ret.append(referenceConfig.getGroup()).append("/");
    }
    ret.append(iName);
    if (!StringUtils.isBlank(referenceConfig.getVersion())) {
        ret.append(":").append(referenceConfig.getVersion());
    }
    return ret.toString();
}
 
开发者ID:linux-china,项目名称:dubbo3,代码行数:21,代码来源:ReferenceConfigCache.java


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