當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。