use of org.apache.servicecomb.swagger.engine.SwaggerConsumerOperation in project incubator-servicecomb-java-chassis by apache.
the class LocalProducerInvoker method invoke.
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
invocation = new SwaggerInvocation();
SwaggerConsumerOperation consumerOp = consumer.findOperation(method.getName());
SwaggerProducerOperation producerOp = producer.findOperation(consumerOp.getSwaggerMethod().getName());
consumerOp.getArgumentsMapper().toInvocation(args, invocation);
CompletableFuture<Object> future = new CompletableFuture<>();
producerOp.invoke(invocation, ar -> {
producerResponse = ar;
Object realResult = consumerOp.getResponseMapper().mapResponse(producerResponse);
future.complete(realResult);
});
if (CompletableFuture.class.equals(method.getReturnType())) {
return future;
}
return future.get();
}
use of org.apache.servicecomb.swagger.engine.SwaggerConsumerOperation in project incubator-servicecomb-java-chassis by apache.
the class Invoker method invoke.
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (swaggerConsumer == null) {
synchronized (this) {
if (swaggerConsumer == null) {
prepare();
}
}
}
SwaggerConsumerOperation consumerOperation = swaggerConsumer.findOperation(method.getName());
Invocation invocation = InvocationFactory.forConsumer(referenceConfig, schemaMeta, consumerOperation.getSwaggerMethod().getName(), null);
consumerOperation.getArgumentsMapper().toInvocation(args, invocation);
if (CompletableFuture.class.equals(method.getReturnType())) {
return completableFutureInvoke(invocation, consumerOperation);
}
return syncInvoke(invocation, consumerOperation);
}
Aggregations