本文整理汇总了Java中com.alibaba.dubbo.config.ProtocolConfig类的典型用法代码示例。如果您正苦于以下问题:Java ProtocolConfig类的具体用法?Java ProtocolConfig怎么用?Java ProtocolConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProtocolConfig类属于com.alibaba.dubbo.config包,在下文中一共展示了ProtocolConfig类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.alibaba.dubbo.config.ProtocolConfig; //导入依赖的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: testXmlOverrideProperties
import com.alibaba.dubbo.config.ProtocolConfig; //导入依赖的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();
}
}
示例3: testSystemPropertyOverrideMultiProtocol
import com.alibaba.dubbo.config.ProtocolConfig; //导入依赖的package包/类
@Test
public void testSystemPropertyOverrideMultiProtocol() throws Exception {
System.setProperty("dubbo.protocol.dubbo.port", "20814");
System.setProperty("dubbo.protocol.rmi.port", "10914");
ClassPathXmlApplicationContext providerContext = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/override-multi-protocol.xml");
providerContext.start();
try {
ProtocolConfig dubbo = (ProtocolConfig) providerContext.getBean("dubbo");
assertEquals(20814, dubbo.getPort().intValue());
ProtocolConfig rmi = (ProtocolConfig) providerContext.getBean("rmi");
assertEquals(10914, rmi.getPort().intValue());
} finally {
System.setProperty("dubbo.protocol.dubbo.port", "");
System.setProperty("dubbo.protocol.rmi.port", "");
providerContext.stop();
providerContext.close();
}
}
示例4: testSystemPropertyOverrideReferenceConfig
import com.alibaba.dubbo.config.ProtocolConfig; //导入依赖的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", "");
}
}
示例5: fillDubboService
import com.alibaba.dubbo.config.ProtocolConfig; //导入依赖的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;
}
示例6: main
import com.alibaba.dubbo.config.ProtocolConfig; //导入依赖的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
}