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


Java ProtocolConfig.setPort方法代码示例

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


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

示例1: testProtocolRandomPort

import com.alibaba.dubbo.config.ProtocolConfig; //导入方法依赖的package包/类
@Test
public void testProtocolRandomPort() throws Exception {
    ServiceConfig<DemoService> demoService = null;
    ServiceConfig<HelloService> helloService = null;

    ApplicationConfig application = new ApplicationConfig();
    application.setName("test-protocol-random-port");

    RegistryConfig registry = new RegistryConfig();
    registry.setAddress("N/A");

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

    demoService = new ServiceConfig<DemoService>();
    demoService.setInterface(DemoService.class);
    demoService.setRef(new DemoServiceImpl());
    demoService.setApplication(application);
    demoService.setRegistry(registry);
    demoService.setProtocol(protocol);

    helloService = new ServiceConfig<HelloService>();
    helloService.setInterface(HelloService.class);
    helloService.setRef(new HelloServiceImpl());
    helloService.setApplication(application);
    helloService.setRegistry(registry);
    helloService.setProtocol(protocol);

    try {
        demoService.export();
        helloService.export();

        Assert.assertEquals(demoService.getExportedUrls().get(0).getPort(),
                            helloService.getExportedUrls().get(0).getPort());
    } finally {
        unexportService(demoService);
        unexportService(helloService);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:41,代码来源:ConfigTest.java

示例2: protocolConfig

import com.alibaba.dubbo.config.ProtocolConfig; //导入方法依赖的package包/类
@Bean
public ProtocolConfig protocolConfig() {
	ProtocolConfig protocol = new ProtocolConfig();
	protocol.setCharset("UTF-8");
	protocol.setName("dubbo");
	protocol.setPort(protocolPort);
	return protocol;
}
 
开发者ID:swxiao,项目名称:bubble2,代码行数:9,代码来源:DubboProviderConfiguration.java

示例3: protocalConfig

import com.alibaba.dubbo.config.ProtocolConfig; //导入方法依赖的package包/类
@Bean
public ProtocolConfig protocalConfig(){
	ProtocolConfig protocolConfig = new ProtocolConfig();
	protocolConfig.setName(getProtocolName());
	protocolConfig.setPort(getProtocalPort());
	return protocolConfig;
}
 
开发者ID:mazhaoyong,项目名称:dubbox-zookeeper-demo,代码行数:8,代码来源:DubboConfig.java

示例4: dubboProtocol

import com.alibaba.dubbo.config.ProtocolConfig; //导入方法依赖的package包/类
@Bean
public ProtocolConfig dubboProtocol() {
  final ProtocolConfig protocol = new ProtocolConfig();
  protocol.setName(dubboProperty.getProtocolName());
  protocol.setPort(dubboProperty.getProtocolPort());
  return protocol;
}
 
开发者ID:Yirendai,项目名称:cicada,代码行数:8,代码来源:DubboConfiguration.java

示例5: testProtocolRandomPort

import com.alibaba.dubbo.config.ProtocolConfig; //导入方法依赖的package包/类
@Test
public void testProtocolRandomPort() throws Exception {
    ServiceConfig<DemoService> demoService = null;
    ServiceConfig<HelloService> helloService = null;

    ApplicationConfig application = new ApplicationConfig();
    application.setName("test-protocol-random-port");

    RegistryConfig registry = new RegistryConfig();
    registry.setAddress("N/A");

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

    demoService = new ServiceConfig<DemoService>();
    demoService.setInterface(DemoService.class);
    demoService.setRef(new DemoServiceImpl());
    demoService.setApplication(application);
    demoService.setRegistry(registry);
    demoService.setProtocol(protocol);

    helloService = new ServiceConfig<HelloService>();
    helloService.setInterface(HelloService.class);
    helloService.setRef(new HelloServiceImpl());
    helloService.setApplication(application);
    helloService.setRegistry(registry);
    helloService.setProtocol(protocol);

    try {
        demoService.export();
        helloService.export();

        Assert.assertEquals(demoService.getExportedUrls().get(0).getPort(),
                helloService.getExportedUrls().get(0).getPort());
    } finally {
        unexportService(demoService);
        unexportService(helloService);
    }
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:41,代码来源:ConfigTest.java

示例6: testApiOverrideProperties

import com.alibaba.dubbo.config.ProtocolConfig; //导入方法依赖的package包/类
@Test
public void testApiOverrideProperties() throws Exception {
    ApplicationConfig application = new ApplicationConfig();
    application.setName("api-override-properties");
    
    RegistryConfig registry = new RegistryConfig();
    registry.setAddress("N/A");
    
    ProtocolConfig protocol = new ProtocolConfig();
    protocol.setName("dubbo");
    protocol.setPort(13123);
    
    ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
    service.setInterface(DemoService.class);
    service.setRef(new DemoServiceImpl());
    service.setApplication(application);
    service.setRegistry(registry);
    service.setProtocol(protocol);
    service.export();
    
    try {
        URL url = service.toUrls().get(0);
        assertEquals("api-override-properties", url.getParameter("application"));
        assertEquals("world", url.getParameter("owner"));
        assertEquals(13123, url.getPort());
        
        ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
        reference.setApplication(new ApplicationConfig("consumer"));
        reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
        reference.setInterface(DemoService.class);
        reference.setUrl("dubbo://127.0.0.1:13123");
        reference.get();
        try {
            url = reference.toUrls().get(0);
            assertEquals("2000", url.getParameter("timeout"));
        } finally {
            reference.destroy();
        }
    } finally {
        service.unexport();
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:43,代码来源:ConfigTest.java

示例7: testSystemPropertyOverrideApi

import com.alibaba.dubbo.config.ProtocolConfig; //导入方法依赖的package包/类
@Test
public void testSystemPropertyOverrideApi() throws Exception {
    System.setProperty("dubbo.application.name", "sysover");
    System.setProperty("dubbo.application.owner", "sysowner");
    System.setProperty("dubbo.registry.address", "N/A");
    System.setProperty("dubbo.protocol.name", "dubbo");
    System.setProperty("dubbo.protocol.port", "20834");
    try {
        ApplicationConfig application = new ApplicationConfig();
        application.setName("aaa");
        
        RegistryConfig registry = new RegistryConfig();
        registry.setAddress("127.0.0.1");
        
        ProtocolConfig protocol = new ProtocolConfig();
        protocol.setName("rmi");
        protocol.setPort(1099);
        
        ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
        service.setInterface(DemoService.class);
        service.setRef(new DemoServiceImpl());
        service.setApplication(application);
        service.setRegistry(registry);
        service.setProtocol(protocol);
        service.export();
        
        try {
            URL url = service.toUrls().get(0);
            assertEquals("sysover", url.getParameter("application"));
            assertEquals("sysowner", url.getParameter("owner"));
            assertEquals("dubbo", url.getProtocol());
            assertEquals(20834, url.getPort());
        } finally {
            service.unexport();
        }
    } finally {
        System.setProperty("dubbo.application.name", "");
        System.setProperty("dubbo.application.owner", "");
        System.setProperty("dubbo.registry.address", "");
        System.setProperty("dubbo.protocol.name", "");
        System.setProperty("dubbo.protocol.port", "");
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:44,代码来源:ConfigTest.java

示例8: testApiOverrideProperties

import com.alibaba.dubbo.config.ProtocolConfig; //导入方法依赖的package包/类
@Test
public void testApiOverrideProperties() throws Exception {
    ApplicationConfig application = new ApplicationConfig();
    application.setName("api-override-properties");

    RegistryConfig registry = new RegistryConfig();
    registry.setAddress("N/A");

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

    ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
    service.setInterface(DemoService.class);
    service.setRef(new DemoServiceImpl());
    service.setApplication(application);
    service.setRegistry(registry);
    service.setProtocol(protocol);
    service.export();

    try {
        URL url = service.toUrls().get(0);
        assertEquals("api-override-properties", url.getParameter("application"));
        assertEquals("world", url.getParameter("owner"));
        assertEquals(13123, url.getPort());

        ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>();
        reference.setApplication(new ApplicationConfig("consumer"));
        reference.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE));
        reference.setInterface(DemoService.class);
        reference.setUrl("dubbo://127.0.0.1:13123");
        reference.get();
        try {
            url = reference.toUrls().get(0);
            assertEquals("2000", url.getParameter("timeout"));
        } finally {
            reference.destroy();
        }
    } finally {
        service.unexport();
    }
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:43,代码来源:ConfigTest.java

示例9: testSystemPropertyOverrideApi

import com.alibaba.dubbo.config.ProtocolConfig; //导入方法依赖的package包/类
@Test
public void testSystemPropertyOverrideApi() throws Exception {
    System.setProperty("dubbo.application.name", "sysover");
    System.setProperty("dubbo.application.owner", "sysowner");
    System.setProperty("dubbo.registry.address", "N/A");
    System.setProperty("dubbo.protocol.name", "dubbo");
    System.setProperty("dubbo.protocol.port", "20834");
    try {
        ApplicationConfig application = new ApplicationConfig();
        application.setName("aaa");

        RegistryConfig registry = new RegistryConfig();
        registry.setAddress("127.0.0.1");

        ProtocolConfig protocol = new ProtocolConfig();
        protocol.setName("rmi");
        protocol.setPort(1099);

        ServiceConfig<DemoService> service = new ServiceConfig<DemoService>();
        service.setInterface(DemoService.class);
        service.setRef(new DemoServiceImpl());
        service.setApplication(application);
        service.setRegistry(registry);
        service.setProtocol(protocol);
        service.export();

        try {
            URL url = service.toUrls().get(0);
            assertEquals("sysover", url.getParameter("application"));
            assertEquals("sysowner", url.getParameter("owner"));
            assertEquals("dubbo", url.getProtocol());
            assertEquals(20834, url.getPort());
        } finally {
            service.unexport();
        }
    } finally {
        System.setProperty("dubbo.application.name", "");
        System.setProperty("dubbo.application.owner", "");
        System.setProperty("dubbo.registry.address", "");
        System.setProperty("dubbo.protocol.name", "");
        System.setProperty("dubbo.protocol.port", "");
    }
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:44,代码来源:ConfigTest.java


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