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


Java URL.valueOf方法代码示例

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


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

示例1: testGenricCustomArg

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public void testGenricCustomArg(){
    
    int port = 20880;
    URL consumerurl = URL.valueOf("dubbo://127.0.0.1:"+port+"/test?timeout=2000000"
    );
    Invoker<GenericService> reference = protocol.refer(GenericService.class, consumerurl);
    
    GenericService demoProxy = (GenericService)proxy.getProxy(reference);
    Map<String, Object> arg = new HashMap<String, Object>();
    arg.put("type", "High");
    arg.put("name", "hi");
    
    Object obj = demoProxy.$invoke("get", new String[]{"com.alibaba.dubbo.rpc.CustomArgument"}, new Object[]{arg});
    System.out.println("obj---------->"+obj);
    reference.destroy();
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:17,代码来源:EnumBak.java

示例2: handle

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public Page handle(URL url) {
    String provider = url.getParameterAndDecoded("provider");
    if (provider == null || provider.length() == 0) {
        throw new IllegalArgumentException("Please input provider parameter.");
    }
    URL providerUrl = URL.valueOf(provider);
    RegistryContainer.getInstance().getRegistry().unregister(providerUrl);
    String parameter;
    if (url.hasParameter("service")) {
        parameter = "service=" + url.getParameter("service");
    } else if (url.hasParameter("host")) {
        parameter = "host=" + url.getParameter("host");
    } else if (url.hasParameter("application")) {
        parameter = "application=" + url.getParameter("application");
    } else {
        parameter = "service=" + providerUrl.getServiceInterface();
    }
    return new Page("<script type=\"text/javascript\">window.location.href=\"providers.html?" + parameter + "\";</script>");
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:20,代码来源:UnregisterPageHandler.java

示例3: testExportService

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Ignore
    @Test
    public void testExportService() throws InterruptedException{
        int port = NetUtils.getAvailablePort();
        URL serviceurl = URL.valueOf("dubbo://127.0.0.1:"+port+"/test?proxy=jdk&timeout="+Integer.MAX_VALUE
                );
        DemoService demo = new DemoServiceImpl();
        Invoker<DemoService> invoker = proxy.getInvoker(demo, DemoService.class, serviceurl);
        protocol.export(invoker);
        synchronized (EnumBak.class) {
            EnumBak.class.wait();
        }
        
//        URL consumerurl = serviceurl;
//        Invoker<DemoService> reference = protocol.refer(DemoService.class, consumerurl);
//        DemoService demoProxy = (DemoService)proxyFactory.createProxy(reference);
////        System.out.println(demoProxy.getThreadName());
//        System.out.println("byte:"+demoProxy.getbyte((byte)-128));
//        
//        invoker.destroy();
//        reference.destroy();
    }
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:23,代码来源:EnumBak.java

示例4: testLoadDefaultActivateExtension

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Test
public void testLoadDefaultActivateExtension() throws Exception {
    // test default
    URL url = URL.valueOf("test://localhost/test?ext=order1,default");
    List<ActivateExt1> list = ExtensionLoader.getExtensionLoader(ActivateExt1.class)
            .getActivateExtension(url, "ext", "default_group");
    Assert.assertEquals(2, list.size());
    Assert.assertTrue(list.get(0).getClass() == OrderActivateExtImpl1.class);
    Assert.assertTrue(list.get(1).getClass() == ActivateExt1Impl1.class);
    
    url = URL.valueOf("test://localhost/test?ext=default,order1");
    list = ExtensionLoader.getExtensionLoader(ActivateExt1.class)
            .getActivateExtension(url, "ext", "default_group");
    Assert.assertEquals(2, list.size());
    Assert.assertTrue(list.get(0).getClass() == ActivateExt1Impl1.class);
    Assert.assertTrue(list.get(1).getClass() == OrderActivateExtImpl1.class);
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:18,代码来源:ExtensionLoaderTest.java

示例5: testTimeOut

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Test
public void testTimeOut() {
    HessianServiceImpl server = new HessianServiceImpl();
    ProxyFactory proxyFactory = ExtensionLoader.getExtensionLoader(ProxyFactory.class).getAdaptiveExtension();
    Protocol protocol = ExtensionLoader.getExtensionLoader(Protocol.class).getAdaptiveExtension();
    URL url = URL.valueOf("hessian://127.0.0.1:5342/" + HessianService.class.getName() + "?version=1.0.0&timeout=10");
    Exporter<HessianService> exporter = protocol.export(proxyFactory.getInvoker(server, HessianService.class, url));
    Invoker<HessianService> invoker = protocol.refer(HessianService.class, url);
    HessianService client = proxyFactory.getProxy(invoker);
    try {
        client.timeOut(6000);
        fail();
    } catch (RpcException expected) {
        Assert.assertEquals(true, expected.isTimeout());
    }finally{
        invoker.destroy();
        exporter.unexport();
    }
    
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:21,代码来源:HessianProtocolTest.java

示例6: testDefaultPort

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Test
public void testDefaultPort() {
    MulticastRegistry multicastRegistry = new MulticastRegistry(URL.valueOf("multicast://224.5.6.7"));
    try {
        MulticastSocket multicastSocket = multicastRegistry.getMutilcastSocket();
        Assert.assertEquals(1234, multicastSocket.getLocalPort());
    } finally {
        multicastRegistry.destroy();
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:11,代码来源:MulticastRegistryTest.java

示例7: testDeprecatedFilter

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Test
public void testDeprecatedFilter() {
    URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1&echo." + Constants.DEPRECATED_KEY + "=true");
    LogUtil.start();
    deprecatedFilter.invoke(new MyInvoker<DemoService>(url), new MockInvocation());
    assertEquals(1,
                 LogUtil.findMessage("The service method com.alibaba.dubbo.rpc.support.DemoService.echo(String) is DEPRECATED"));
    LogUtil.stop();
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:10,代码来源:DeprecatedFilterTest.java

示例8: testRoute_NoForce

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Test
public void testRoute_NoForce(){
    Router router = new ConditionRouterFactory().getRouter(getRouteUrl("host = " + NetUtils.getLocalHost() + " => " + " host = 1.2.3.4"));
    List<Invoker<String>> invokers = new ArrayList<Invoker<String>>();
    Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService")) ;
    Invoker<String> invoker2 = new MockInvoker<String>(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":20880/com.foo.BarService")) ;
    Invoker<String> invoker3 = new MockInvoker<String>(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":20880/com.foo.BarService")) ;
    invokers.add(invoker1);
    invokers.add(invoker2);
    invokers.add(invoker3);
    List<Invoker<String>> fileredInvokers = router.route(invokers, URL.valueOf("consumer://" + NetUtils.getLocalHost() + "/com.foo.BarService"), new RpcInvocation());
    Assert.assertEquals(invokers, fileredInvokers);
}
 
开发者ID:flychao88,项目名称:dubbocloud,代码行数:14,代码来源:ConditionRouterTest.java

示例9: testEnumCompat

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
public void testEnumCompat(){
    int port = 20880;
    URL consumerurl = URL.valueOf("dubbo://127.0.0.1:"+port+"/test?timeout="+Integer.MAX_VALUE
    );
    Invoker<DemoService> reference = protocol.refer(DemoService.class, consumerurl);
    DemoService demoProxy = (DemoService)proxy.getProxy(reference);
    Type type = demoProxy.enumlength(Type.High);
    System.out.println(type);
    Assert.assertEquals(Type.High, type);
    reference.destroy();
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:12,代码来源:EnumBak.java

示例10: testSetContext

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Test
public void testSetContext(){
    URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1");
    Invoker<DemoService> invoker = new MyInvoker<DemoService>(url);
    Invocation invocation = new MockInvocation();
    consumerContextFilter.invoke(invoker, invocation);
    assertEquals(invoker,RpcContext.getContext().getInvoker());
    assertEquals(invocation,RpcContext.getContext().getInvocation());
    assertEquals(NetUtils.getLocalHost() + ":0",RpcContext.getContext().getLocalAddressString());
    assertEquals("test:11",RpcContext.getContext().getRemoteAddressString());
    
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:13,代码来源:ConsumerContextFilterTest.java

示例11: testRegistryFactoryCache

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Test
public void testRegistryFactoryCache() throws Exception {
    URL url = URL.valueOf("dubbo://" + NetUtils.getLocalAddress().getHostAddress() + ":2233");
    Registry registry1 = registryFactory.getRegistry(url);
    Registry registry2 = registryFactory.getRegistry(url);
    Assert.assertEquals(registry1, registry2);
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:8,代码来源:AbstractRegistryFactoryTest.java

示例12: test_Normal_ChannelReadOnly

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Test
public void test_Normal_ChannelReadOnly() throws Exception{
    URL url = URL.valueOf("dubbo://127.0.0.1:20883/hi");
    ProtocolUtils.export(new DemoServiceImpl(), IDemoService.class, url);
    
    DubboInvoker<?> invoker = (DubboInvoker<?>)protocol.refer(IDemoService.class, url);
    Assert.assertEquals(true, invoker.isAvailable());
    
    getClients(invoker)[0].setAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY, Boolean.TRUE);
    
    Assert.assertEquals(false, invoker.isAvailable());
 
    //恢复状态,invoker共享连接
    getClients(invoker)[0].removeAttribute(Constants.CHANNEL_ATTRIBUTE_READONLY_KEY);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:16,代码来源:DubboInvokerAvilableTest.java

示例13: testWithoutCount

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Test
public void testWithoutCount() throws Exception {
    URL url = URL.valueOf("test://test");
    url = url.addParameter(Constants.INTERFACE_KEY,
                           "com.alibaba.dubbo.rpc.file.TpsService");
    url = url.addParameter(Constants.TPS_LIMIT_RATE_KEY, 5);
    Invoker<TpsLimitFilterTest> invoker = new MyInvoker<TpsLimitFilterTest>(url);
    Invocation invocation = new MockInvocation();
    filter.invoke(invoker, invocation);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:11,代码来源:TpsLimitFilterTest.java

示例14: testRoute_Empty_HostFilter

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
@Test
public void testRoute_Empty_HostFilter(){
    Router router = new ConditionRouterFactory().getRouter(getRouteUrl(" => " + " host = " + NetUtils.getLocalHost()));
    List<Invoker<String>> invokers = new ArrayList<Invoker<String>>();
    Invoker<String> invoker1 = new MockInvoker<String>(URL.valueOf("dubbo://10.20.3.3:20880/com.foo.BarService")) ;
    Invoker<String> invoker2 = new MockInvoker<String>(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":20880/com.foo.BarService")) ;
    Invoker<String> invoker3 = new MockInvoker<String>(URL.valueOf("dubbo://" + NetUtils.getLocalHost() + ":20880/com.foo.BarService")) ;
    invokers.add(invoker1);
    invokers.add(invoker2);
    invokers.add(invoker3);
    List<Invoker<String>> fileredInvokers = router.route(invokers, URL.valueOf("consumer://" + NetUtils.getLocalHost() + "/com.foo.BarService"), new RpcInvocation());
    Assert.assertEquals(2, fileredInvokers.size());
    Assert.assertEquals(invoker2, fileredInvokers.get(0));
    Assert.assertEquals(invoker3, fileredInvokers.get(1));
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:16,代码来源:ConditionRouterTest.java

示例15: getUrl

import com.alibaba.dubbo.common.URL; //导入方法依赖的package包/类
protected URL getUrl() {
    return URL.valueOf(
            "thrift://127.0.0.1:" + PORT + "/" + getInterface().getName() );
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:5,代码来源:AbstractTest.java


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