Java Code Examples for com.alipay.sofa.rpc.core.request.SofaRequest#getMethodArgs()
The following examples show how to use
com.alipay.sofa.rpc.core.request.SofaRequest#getMethodArgs() .
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: SofaRpcProviderInterceptor.java From skywalking with Apache License 2.0 | 6 votes |
/** * Format operation name. e.g. org.apache.skywalking.apm.plugin.test.Test.test(String) * * @return operation name. */ private String generateViewPoint(SofaRequest sofaRequest) { StringBuilder operationName = new StringBuilder(); operationName.append(sofaRequest.getInterfaceName()); operationName.append("." + sofaRequest.getMethodName() + "("); for (String arg : sofaRequest.getMethodArgSigs()) { operationName.append(arg + ","); } if (sofaRequest.getMethodArgs().length > 0) { operationName.delete(operationName.length() - 1, operationName.length()); } operationName.append(")"); return operationName.toString(); }
Example 2
Source File: SofaRpcConsumerInterceptor.java From skywalking with Apache License 2.0 | 6 votes |
/** * Format operation name. e.g. org.apache.skywalking.apm.plugin.test.Test.test(String) * * @return operation name. */ private String generateOperationName(ProviderInfo providerInfo, SofaRequest sofaRequest) { StringBuilder operationName = new StringBuilder(); operationName.append(sofaRequest.getInterfaceName()); operationName.append("." + sofaRequest.getMethodName() + "("); for (String arg : sofaRequest.getMethodArgSigs()) { operationName.append(arg + ","); } if (sofaRequest.getMethodArgs().length > 0) { operationName.delete(operationName.length() - 1, operationName.length()); } operationName.append(")"); return operationName.toString(); }
Example 3
Source File: TestChainFilter2.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { request.getMethodArgs()[0] = request.getMethodArgs()[0] + "_q2"; SofaResponse response = invoker.invoke(request); if (!request.isAsync()) { response.setAppResponse(response.getAppResponse() + "_s2"); } Map<String, Object> context = invoker.getConfigContext(); Assert.assertNotNull(context); invoker.getMethodParam(request.getMethodName(), "invokeType"); invoker.getStringMethodParam(request.getMethodName(), "invokeType", "sync"); invoker.getIntMethodParam(request.getMethodName(), "timeout", 3000); invoker.getBooleanMethodParam(request.getMethodName(), "cache", false); return response; }
Example 4
Source File: TestChainFilter4.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { request.getMethodArgs()[0] = request.getMethodArgs()[0] + "_q4"; SofaResponse response = invoker.invoke(request); if (!request.isAsync()) { response.setAppResponse(response.getAppResponse() + "_s4"); } return response; }
Example 5
Source File: TestChainFilter0.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { request.getMethodArgs()[0] = request.getMethodArgs()[0] + "_q0"; SofaResponse response = invoker.invoke(request); if (!request.isAsync()) { response.setAppResponse(response.getAppResponse() + "_s0"); } return response; }
Example 6
Source File: TestChainFilter7.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { request.getMethodArgs()[0] = request.getMethodArgs()[0] + "_q7"; SofaResponse response = invoker.invoke(request); if (!request.isAsync()) { response.setAppResponse(response.getAppResponse() + "_s7"); } return response; }
Example 7
Source File: TestChainFilter8.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { request.getMethodArgs()[0] = request.getMethodArgs()[0] + "_q8"; SofaResponse response = invoker.invoke(request); if (!request.isAsync()) { response.setAppResponse(response.getAppResponse() + "_s8"); } return response; }
Example 8
Source File: TestChainFilter1.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { request.getMethodArgs()[0] = request.getMethodArgs()[0] + "_q1"; SofaResponse response = invoker.invoke(request); if (!request.isAsync()) { response.setAppResponse(response.getAppResponse() + "_s1"); } return response; }
Example 9
Source File: TestChainFilter3.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { request.getMethodArgs()[0] = request.getMethodArgs()[0] + "_q3"; SofaResponse response = invoker.invoke(request); if (!request.isAsync()) { response.setAppResponse(response.getAppResponse() + "_s3"); } return response; }
Example 10
Source File: TestChainFilter6.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { request.getMethodArgs()[0] = request.getMethodArgs()[0] + "_q6"; SofaResponse response = invoker.invoke(request); if (!request.isAsync()) { response.setAppResponse(response.getAppResponse() + "_s6"); } return response; }
Example 11
Source File: TestSyncFilter.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { interfaceName = request.getInterfaceName(); targetServiceUniqueName = request.getTargetServiceUniqueName(); methodName = request.getMethodName(); invokeType = request.getInvokeType(); targetAppName = request.getTargetAppName(); args = request.getMethodArgs(); return invoker.invoke(request); }
Example 12
Source File: ProtostuffSerializer.java From sofa-rpc with Apache License 2.0 | 5 votes |
protected AbstractByteBuf encodeSofaRequest(SofaRequest sofaRequest, Map<String, String> context) throws SofaRpcException { Object[] args = sofaRequest.getMethodArgs(); if (args.length > 1) { throw buildSerializeError("Protobuf only support one parameter!"); } return encode(args[0], context); }
Example 13
Source File: MsgPackSerializer.java From sofa-rpc with Apache License 2.0 | 5 votes |
protected AbstractByteBuf encodeSofaRequest(SofaRequest sofaRequest, Map<String, String> context) throws SofaRpcException { Object[] args = sofaRequest.getMethodArgs(); if (args.length > 1) { throw buildSerializeError("Msgpack only support one parameter!"); } return encode(args[0], context); }
Example 14
Source File: JacksonSerializer.java From sofa-rpc with Apache License 2.0 | 5 votes |
protected AbstractByteBuf encodeSofaRequest(SofaRequest sofaRequest, Map<String, String> context) throws SofaRpcException { Object[] args = sofaRequest.getMethodArgs(); if (args.length == 1) { return encode(args[0], context); } else { return encode(args, context); } }
Example 15
Source File: SofaRequestHessianSerializer.java From sofa-rpc with Apache License 2.0 | 5 votes |
@Override public AbstractByteBuf encodeObject(SofaRequest sofaRequest, Map<String, String> context) { try { UnsafeByteArrayOutputStream outputStream = new UnsafeByteArrayOutputStream(); Hessian2Output output = new Hessian2Output(outputStream); // 根据SerializeType信息决定序列化器 boolean genericSerialize = context != null && isGenericRequest(context.get(RemotingConstants.HEAD_GENERIC_TYPE)); if (genericSerialize) { output.setSerializerFactory(genericSerializerFactory); } else { output.setSerializerFactory(serializerFactory); } output.writeObject(sofaRequest); final Object[] args = sofaRequest.getMethodArgs(); if (args != null) { for (Object arg : args) { output.writeObject(arg); } } output.close(); return new ByteStreamWrapperByteBuf(outputStream); } catch (IOException e) { throw buildSerializeError(e.getMessage(), e); } }
Example 16
Source File: ProtobufSerializer.java From sofa-rpc with Apache License 2.0 | 5 votes |
protected AbstractByteBuf encodeSofaRequest(SofaRequest sofaRequest, Map<String, String> context) throws SofaRpcException { Object[] args = sofaRequest.getMethodArgs(); if (args.length > 1) { throw buildSerializeError("Protobuf only support one parameter!"); } return encode(args[0], context); }
Example 17
Source File: TestGlobalFilter.java From sofa-rpc-boot-projects with Apache License 2.0 | 5 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { if (request.getInterfaceName() != null && request.getInterfaceName().equals("com.alipay.sofa.rpc.boot.globalfilter.GlobalFilterService")) { if (request.getMethodArgs()[0].equals("globalFilter")) { request.getMethodArgs()[0] = "globalFilter_change"; } } return invoker.invoke(request); }
Example 18
Source File: ComplexTestMix.java From sofa-hessian with Apache License 2.0 | 4 votes |
@Test public void testSofaRequest() throws IOException { SofaRequest request = dg.generateSofaRequest(); // serialization uses GenericHessian ByteArrayOutputStream byteArray = new ByteArrayOutputStream(); Hessian2Output output = new Hessian2Output(byteArray); output.setSerializerFactory(new GenericSerializerFactory()); output.writeObject(request); final Object[] args = request.getMethodArgs(); if (args != null) { for (int i = 0; i < args.length; i++) { output.writeObject(args[i]); } } output.close(); byteArray.close(); // deserialization uses Hessian byte[] body = byteArray.toByteArray(); ByteArrayInputStream bin = new ByteArrayInputStream(body, 0, body.length); Hessian2Input hin = new Hessian2Input(bin); hin.setSerializerFactory(new SerializerFactory()); SofaRequest deRequest = (SofaRequest) hin.readObject(); String[] sig = deRequest.getMethodArgSigs(); Class<?>[] classSig = new Class[sig.length]; final Object[] deArgs = new Object[sig.length]; for (int i = 0; i < deRequest.getMethodArgSigs().length; ++i) { deArgs[i] = hin.readObject(classSig[i]); } deRequest.setMethodArgs(deArgs); bin.close(); hin.close(); assertEquals(request.getTargetServiceUniqueName(), deRequest.getTargetServiceUniqueName()); assertEquals(request.getMethodName(), deRequest.getMethodName()); assertEquals(request.getTargetAppName(), deRequest.getTargetAppName()); assertEquals(request.getRequestProps(), deRequest.getRequestProps()); // 1st argument is a Person, and 2nd argument is an int cmpGPersonEqualPerson((GenericObject) request.getMethodArgs()[0], (Person) deRequest.getMethodArgs()[0]); assertEquals(request.getMethodArgs()[1], deRequest.getMethodArgs()[1]); }
Example 19
Source File: SofaRpcUtils.java From Sentinel with Apache License 2.0 | 4 votes |
public static Object[] getMethodArguments(SofaRequest request) { return request.getMethodArgs(); }
Example 20
Source File: TestFilter.java From sofa-rpc-boot-projects with Apache License 2.0 | 3 votes |
@Override public SofaResponse invoke(FilterInvoker invoker, SofaRequest request) throws SofaRpcException { request.getMethodArgs()[0] = "filter_change"; return invoker.invoke(request); }