Java Code Examples for com.alibaba.dubbo.rpc.RpcInvocation#getArguments()
The following examples show how to use
com.alibaba.dubbo.rpc.RpcInvocation#getArguments() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DubboCodec.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
@Override protected void encodeRequestData(Channel channel, ObjectOutput out, Object data, String version) throws IOException { RpcInvocation inv = (RpcInvocation) data; out.writeUTF(version); out.writeUTF(inv.getAttachment(Constants.PATH_KEY)); out.writeUTF(inv.getAttachment(Constants.VERSION_KEY)); out.writeUTF(inv.getMethodName()); out.writeUTF(ReflectUtils.getDesc(inv.getParameterTypes())); Object[] args = inv.getArguments(); if (args != null) for (int i = 0; i < args.length; i++) { out.writeObject(encodeInvocationArgument(channel, inv, i)); } out.writeObject(inv.getAttachments()); }
Example 2
Source File: CallbackServiceCodec.java From dubbo-2.6.5 with Apache License 2.0 | 6 votes |
public static Object encodeInvocationArgument(Channel channel, RpcInvocation inv, int paraIndex) throws IOException { // get URL directly 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]; } }
Example 3
Source File: DubboCodec.java From dubbox with Apache License 2.0 | 6 votes |
@Override protected void encodeRequestData(Channel channel, ObjectOutput out, Object data) throws IOException { RpcInvocation inv = (RpcInvocation) data; out.writeUTF(inv.getAttachment(Constants.DUBBO_VERSION_KEY, DUBBO_VERSION)); out.writeUTF(inv.getAttachment(Constants.PATH_KEY)); out.writeUTF(inv.getAttachment(Constants.VERSION_KEY)); out.writeUTF(inv.getMethodName()); // NOTICE modified by lishen // TODO if (getSerialization(channel) instanceof OptimizedSerialization && !containComplexArguments(inv)) { out.writeInt(inv.getParameterTypes().length); } else { out.writeInt(-1); out.writeUTF(ReflectUtils.getDesc(inv.getParameterTypes())); } Object[] args = inv.getArguments(); if (args != null) for (int i = 0; i < args.length; i++){ out.writeObject(encodeInvocationArgument(channel, inv, i)); } out.writeObject(inv.getAttachments()); }
Example 4
Source File: CallbackServiceCodec.java From dubbox with Apache License 2.0 | 6 votes |
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]; } }
Example 5
Source File: DubboCodec.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
@Override protected void encodeRequestData(Channel channel, ObjectOutput out, Object data) throws IOException { RpcInvocation inv = (RpcInvocation) data; out.writeUTF(inv.getAttachment(Constants.DUBBO_VERSION_KEY, DUBBO_VERSION)); out.writeUTF(inv.getAttachment(Constants.PATH_KEY)); out.writeUTF(inv.getAttachment(Constants.VERSION_KEY)); out.writeUTF(inv.getMethodName()); // NOTICE modified by lishen // TODO if (getSerialization(channel) instanceof OptimizedSerialization && !containComplexArguments(inv)) { out.writeInt(inv.getParameterTypes().length); } else { out.writeInt(-1); out.writeUTF(ReflectUtils.getDesc(inv.getParameterTypes())); } Object[] args = inv.getArguments(); if (args != null) for (int i = 0; i < args.length; i++){ out.writeObject(encodeInvocationArgument(channel, inv, i)); } out.writeObject(inv.getAttachments()); }
Example 6
Source File: CallbackServiceCodec.java From dubbox-hystrix with Apache License 2.0 | 6 votes |
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]; } }
Example 7
Source File: DubboCodec.java From dubbo3 with Apache License 2.0 | 6 votes |
@Override protected void encodeRequestData(Channel channel, ObjectOutput out, Object data) throws IOException { RpcInvocation inv = (RpcInvocation) data; out.writeUTF(inv.getAttachment(Constants.DUBBO_VERSION_KEY, DUBBO_VERSION)); out.writeUTF(inv.getAttachment(Constants.PATH_KEY)); out.writeUTF(inv.getAttachment(Constants.VERSION_KEY)); out.writeUTF(inv.getMethodName()); out.writeUTF(ReflectUtils.getDesc(inv.getParameterTypes())); Object[] args = inv.getArguments(); if (args != null) for (int i = 0; i < args.length; i++){ out.writeObject(encodeInvocationArgument(channel, inv, i)); } out.writeObject(inv.getAttachments()); }
Example 8
Source File: DubboCodec.java From dubbox with Apache License 2.0 | 6 votes |
@Override protected void encodeRequestData(Channel channel, ObjectOutput out, Object data) throws IOException { RpcInvocation inv = (RpcInvocation) data; out.writeUTF(inv.getAttachment(Constants.DUBBO_VERSION_KEY, DUBBO_VERSION)); out.writeUTF(inv.getAttachment(Constants.PATH_KEY)); out.writeUTF(inv.getAttachment(Constants.VERSION_KEY)); out.writeUTF(inv.getMethodName()); // NOTICE modified by lishen // TODO if (getSerialization(channel) instanceof OptimizedSerialization && !containComplexArguments(inv)) { out.writeInt(inv.getParameterTypes().length); } else { out.writeInt(-1); out.writeUTF(ReflectUtils.getDesc(inv.getParameterTypes())); } Object[] args = inv.getArguments(); if (args != null) for (int i = 0; i < args.length; i++){ out.writeObject(encodeInvocationArgument(channel, inv, i)); } out.writeObject(inv.getAttachments()); }
Example 9
Source File: CallbackServiceCodec.java From dubbox with Apache License 2.0 | 6 votes |
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]; } }
Example 10
Source File: CallbackServiceCodec.java From dubbox with Apache License 2.0 | 6 votes |
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]; } }
Example 11
Source File: DubboCodec.java From dubbox with Apache License 2.0 | 5 votes |
private boolean containComplexArguments(RpcInvocation invocation) { for (int i = 0; i < invocation.getParameterTypes().length; i++) { if (invocation.getArguments()[i] == null || invocation.getParameterTypes()[i] != invocation.getArguments()[i].getClass()) { return true; } } return false; }
Example 12
Source File: DubboCodec.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
private boolean containComplexArguments(RpcInvocation invocation) { for (int i = 0; i < invocation.getParameterTypes().length; i++) { if (invocation.getArguments()[i] == null || invocation.getParameterTypes()[i] != invocation.getArguments()[i].getClass()) { return true; } } return false; }
Example 13
Source File: DubboCodec.java From dubbox with Apache License 2.0 | 5 votes |
private boolean containComplexArguments(RpcInvocation invocation) { for (int i = 0; i < invocation.getParameterTypes().length; i++) { if (invocation.getArguments()[i] == null || invocation.getParameterTypes()[i] != invocation.getArguments()[i].getClass()) { return true; } } return false; }
Example 14
Source File: DubboCodec.java From dubbox with Apache License 2.0 | 5 votes |
@Override protected void encodeRequestData(Channel channel, ObjectOutput out, Object data) throws IOException { RpcInvocation inv = (RpcInvocation) data; out.writeUTF(inv.getAttachment(Constants.DUBBO_VERSION_KEY, DUBBO_VERSION)); out.writeUTF(inv.getAttachment(Constants.PATH_KEY)); out.writeUTF(inv.getAttachment(Constants.VERSION_KEY)); out.writeUTF(inv.getMethodName()); // NOTICE modified by lishen // TODO if (getSerialization(channel) instanceof OptimizedSerialization) { if (!containComplexArguments(inv)) { out.writeInt(inv.getParameterTypes().length); } else { out.writeInt(-1); } } else { out.writeUTF(ReflectUtils.getDesc(inv.getParameterTypes())); } Object[] args = inv.getArguments(); if (args != null) for (int i = 0; i < args.length; i++){ out.writeObject(encodeInvocationArgument(channel, inv, i)); } out.writeObject(inv.getAttachments()); }
Example 15
Source File: DubboCodec.java From dubbox with Apache License 2.0 | 5 votes |
private boolean containComplexArguments(RpcInvocation invocation) { for (int i = 0; i < invocation.getParameterTypes().length; i++) { if (invocation.getArguments()[i] == null || invocation.getParameterTypes()[i] != invocation.getArguments()[i].getClass()) { return true; } } return false; }