Java Code Examples for org.apache.servicecomb.core.Invocation#onBusinessFinish()
The following examples show how to use
org.apache.servicecomb.core.Invocation#onBusinessFinish() .
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: ProducerOperationHandler.java From servicecomb-java-chassis with Apache License 2.0 | 6 votes |
public Response doInvoke(Invocation invocation, SwaggerProducerOperation producerOperation) { Response response; try { invocation.onBusinessMethodStart(); Object[] args = invocation.toProducerArguments(); for (ProducerInvokeExtension producerInvokeExtension : producerOperation.getProducerInvokeExtenstionList()) { producerInvokeExtension.beforeMethodInvoke(invocation, producerOperation, args); } Object result = producerOperation.getProducerMethod().invoke(producerOperation.getProducerInstance(), args); response = producerOperation.getResponseMapper().mapResponse(invocation.getStatus(), result); invocation.onBusinessMethodFinish(); invocation.onBusinessFinish(); } catch (Throwable e) { if (shouldPrintErrorLog(e)) { invocation.getTraceIdLogger().error(LOGGER, "unexpected error {},", invocation.getInvocationQualifiedName(), e); } invocation.onBusinessMethodFinish(); invocation.onBusinessFinish(); response = processException(invocation, e); } return response; }
Example 2
Source File: ProducerOperationHandler.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void doCompletableFutureInvoke(Invocation invocation, SwaggerProducerOperation producerOperation, AsyncResponse asyncResp) { try { invocation.onBusinessMethodStart(); Object[] args = invocation.toProducerArguments(); for (ProducerInvokeExtension producerInvokeExtension : producerOperation.getProducerInvokeExtenstionList()) { producerInvokeExtension.beforeMethodInvoke(invocation, producerOperation, args); } Object result = producerOperation.getProducerMethod().invoke(producerOperation.getProducerInstance(), args); invocation.onBusinessMethodFinish(); ((CompletableFuture<Object>) result).whenComplete((realResult, ex) -> { invocation.onBusinessFinish(); if (ex == null) { asyncResp.handle(producerOperation.getResponseMapper().mapResponse(invocation.getStatus(), realResult)); return; } asyncResp.handle(processException(invocation, ex)); }); } catch (Throwable e) { if (shouldPrintErrorLog(e)) { invocation.getTraceIdLogger().error(LOGGER, "unexpected error {},", invocation.getInvocationQualifiedName(), e); } invocation.onBusinessMethodFinish(); invocation.onBusinessFinish(); asyncResp.handle(processException(invocation, e)); } }
Example 3
Source File: ProducerOperationFilter.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
private void whenComplete(Invocation invocation, Throwable throwable) { if (throwable != null) { Throwable unwrapped = Exceptions.unwrap(throwable); if (shouldPrintErrorLog(unwrapped)) { LOGGER.error("unexpected error, invocation={},", invocation.getInvocationQualifiedName(), unwrapped); } } invocation.onBusinessMethodFinish(); invocation.onBusinessFinish(); }