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


Java RpcInvocation.setAttachment方法代码示例

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


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

示例1: encodeInvocationArgument

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
public static Object encodeInvocationArgument(Channel channel, RpcInvocation inv, int paraIndex) throws IOException{
    //encode时可直接获取url
    URL url = inv.getInvoker() == null ? null : inv.getInvoker().getUrl();
    byte callbackstatus = isCallBack(url, inv.getMethodName(), paraIndex);
    Object[] args = inv.getArguments();
    Class<?>[] pts = inv.getParameterTypes();
    switch (callbackstatus) {
        case CallbackServiceCodec.CALLBACK_NONE:
            return args[paraIndex];
        case CallbackServiceCodec.CALLBACK_CREATE:
            inv.setAttachment(INV_ATT_CALLBACK_KEY + paraIndex , exportOrunexportCallbackService(channel, url, pts[paraIndex], args[paraIndex], true));
            return null;
        case CallbackServiceCodec.CALLBACK_DESTROY:
            inv.setAttachment(INV_ATT_CALLBACK_KEY + paraIndex, exportOrunexportCallbackService(channel, url, pts[paraIndex], args[paraIndex], false));
            return null;
        default:
            return args[paraIndex];
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:20,代码来源:CallbackServiceCodec.java

示例2: testNotify_MockProviderOnly

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
/**
 * 测试mock provider下发
 */
@Test
public void testNotify_MockProviderOnly() {
	RegistryDirectory registryDirectory = getRegistryDirectory();
	
	List<URL> serviceUrls = new ArrayList<URL>();
    serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1"));
    serviceUrls.add(SERVICEURL2.addParameter("methods", "getXXX1,getXXX2"));
    serviceUrls.add(SERVICEURL.setProtocol(Constants.MOCK_PROTOCOL));

    registryDirectory.notify(serviceUrls);
    Assert.assertEquals(true, registryDirectory.isAvailable());
    invocation = new RpcInvocation();

    List invokers = registryDirectory.list(invocation);
    Assert.assertEquals(2, invokers.size());
	
    RpcInvocation mockinvocation = new RpcInvocation();
    mockinvocation.setAttachment(Constants.INVOCATION_NEED_MOCK, "true");
    invokers = registryDirectory.list(mockinvocation);
    Assert.assertEquals(1, invokers.size());
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:25,代码来源:RegistryDirectoryTest.java

示例3: testNotify_MockProviderOnly

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
/**
 * 测试mock provider下发
 */
@Test
public void testNotify_MockProviderOnly() {
    RegistryDirectory registryDirectory = getRegistryDirectory();

    List<URL> serviceUrls = new ArrayList<URL>();
    serviceUrls.add(SERVICEURL.addParameter("methods", "getXXX1"));
    serviceUrls.add(SERVICEURL2.addParameter("methods", "getXXX1,getXXX2"));
    serviceUrls.add(SERVICEURL.setProtocol(Constants.MOCK_PROTOCOL));

    registryDirectory.notify(serviceUrls);
    Assert.assertEquals(true, registryDirectory.isAvailable());
    invocation = new RpcInvocation();

    List invokers = registryDirectory.list(invocation);
    Assert.assertEquals(2, invokers.size());

    RpcInvocation mockinvocation = new RpcInvocation();
    mockinvocation.setAttachment(Constants.INVOCATION_NEED_MOCK, "true");
    invokers = registryDirectory.list(mockinvocation);
    Assert.assertEquals(1, invokers.size());
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:25,代码来源:RegistryDirectoryTest.java

示例4: createInvocation

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
private Invocation createInvocation(Channel channel, URL url, String methodKey) {
    String method = url.getParameter(methodKey);
    if (method == null || method.length() == 0) {
        return null;
    }
    RpcInvocation invocation = new RpcInvocation(method, new Class<?>[0], new Object[0]);
    invocation.setAttachment(Constants.PATH_KEY, url.getPath());
    invocation.setAttachment(Constants.GROUP_KEY, url.getParameter(Constants.GROUP_KEY));
    invocation.setAttachment(Constants.INTERFACE_KEY, url.getParameter(Constants.INTERFACE_KEY));
    invocation.setAttachment(Constants.VERSION_KEY, url.getParameter(Constants.VERSION_KEY));
    if (url.getParameter(Constants.STUB_EVENT_KEY, false)){
        invocation.setAttachment(Constants.STUB_EVENT_KEY, Boolean.TRUE.toString());
    }
    return invocation;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:16,代码来源:DubboProtocol.java

示例5: createRequest

import com.alibaba.dubbo.rpc.RpcInvocation; //导入方法依赖的package包/类
private Request createRequest() {

        RpcInvocation invocation = new RpcInvocation();

        invocation.setMethodName( "echoString" );

        invocation.setArguments( new Object[]{ "Hello, World!" } );

        invocation.setParameterTypes( new Class<?>[]{ String.class } );

        invocation.setAttachment( Constants.INTERFACE_KEY, Demo.Iface.class.getName() );

        Request request = new Request( 1L );

        request.setData( invocation );

        return request;

    }
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:20,代码来源:ThriftCodecTest.java


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