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


Java ApplicationConfig类代码示例

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


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

示例1: getCaller

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

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

示例3: init

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

示例4: testXmlOverrideProperties

import com.alibaba.dubbo.config.ApplicationConfig; //导入依赖的package包/类
@Test
public void testXmlOverrideProperties() throws Exception {
    ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/xml-override-properties.xml");
    providerContext.start();
    try {
        ApplicationConfig application = (ApplicationConfig) providerContext.getBean("application");
        assertEquals("demo-provider", application.getName());
        assertEquals("world", application.getOwner());
        
        RegistryConfig registry = (RegistryConfig) providerContext.getBean("registry");
        assertEquals("N/A", registry.getAddress());
        
        ProtocolConfig dubbo = (ProtocolConfig) providerContext.getBean("dubbo");
        assertEquals(20813, dubbo.getPort().intValue());
        
    } finally {
        providerContext.stop();
        providerContext.close();
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:21,代码来源:ConfigTest.java

示例5: testGenericServiceConfig

import com.alibaba.dubbo.config.ApplicationConfig; //导入依赖的package包/类
@Test
public void testGenericServiceConfig() throws Exception {
    ServiceConfig<GenericService> service = new ServiceConfig<GenericService>();
    service.setApplication(new ApplicationConfig("test"));
    service.setRegistry(new RegistryConfig("mock://localhost"));
    service.setInterface(DemoService.class.getName());
    service.setGeneric(Constants.GENERIC_SERIALIZATION_BEAN);
    service.setRef(new GenericService(){

        public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException {
            return null;
        }
    });
    try {
        service.export();
        Collection<Registry> collection = MockRegistryFactory.getCachedRegistry();
        MockRegistry registry = (MockRegistry)collection.iterator().next();
        URL url = registry.getRegistered().get(0);
        Assert.assertEquals(Constants.GENERIC_SERIALIZATION_BEAN, url.getParameter(Constants.GENERIC_KEY));
    } finally {
        MockRegistryFactory.cleanCachedRegistry();
        service.unexport();
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:25,代码来源:ConfigTest.java

示例6: getAppName

import com.alibaba.dubbo.config.ApplicationConfig; //导入依赖的package包/类
public static String getAppName(final String defaultValue) {
  String retValue = null;
  final ApplicationConfig application = getBean(ApplicationConfig.class, null);
  if (application != null) {
    retValue = application.getName();
  }

  if (StringUtils.isBlank(retValue) && applicationContext != null) {
    retValue = applicationContext.getApplicationName();
  }

  if (StringUtils.isBlank(retValue)) {
    retValue = defaultValue;
  }

  return retValue;
}
 
开发者ID:junzixiehui,项目名称:godeye,代码行数:18,代码来源:SpringContextUtil.java

示例7: createClient

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

示例8: getService

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

示例9: fillDubboService

import com.alibaba.dubbo.config.ApplicationConfig; //导入依赖的package包/类
public ServiceConfig<GenericService> fillDubboService(MockService mockService, com.tony.test.mock.po.RegistryConfig registryConfig,
        com.tony.test.mock.po.ProtocolConfig protocolConfig, MockGenericService tmpMockservice) {
    ServiceConfig<GenericService> service = new ServiceConfig<GenericService>();
    service.setInterface(mockService.getServiceInterface());
    service.setRef(tmpMockservice); // 指向一个通用服务实现 
    RegistryConfig registry = createRegistry(registryConfig.getRegistryAddress(), registryConfig.getRegistryTimeout());
    service.setRegistry(registry);
    service.setProtocols(Lists.newArrayList(new ProtocolConfig(protocolConfig.getProtocolName(), protocolConfig.getProtocolPort())));
    if (!StringUtils.isBlank(mockService.getGroupName())) {
        service.setGroup(mockService.getGroupName());
    }
    service.setTimeout(mockService.getTimeout());
    service.setRetries(mockService.getRetries());
    service.setApplication(new ApplicationConfig(mockService.getApplicationName()));
    return service;
}
 
开发者ID:tonyruiyu,项目名称:dubbo-mock,代码行数:17,代码来源:DubboServiceConfig.java

示例10: main

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

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

    ProtocolConfig protocol = new ProtocolConfig();
    protocol.setName("dubbo");
    protocol.setPort(20882);

    ServiceConfig<DemoService> service = new ServiceConfig<>();
    service.setApplication(application);
    service.setRegistry(registry);
    service.setProtocol(protocol);
    service.setInterface(DemoService.class);
    service.setRef(new DemoServiceImpl2());
    service.setVersion("1.0.0");

    service.export();

    System.in.read(); // press any key to exit
}
 
开发者ID:javahongxi,项目名称:whatsmars,代码行数:24,代码来源:Provider.java


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