/** * Builds an object that can be used to resume the polling of the operation. * @return The OperationDescription. */ public OperationDescription buildDescription() { if (this.isDone()) { return null; } return new OperationDescription( this.pollStrategy.methodParser().fullyQualifiedMethodName(), this.pollStrategy.strategyData(), this.originalHttpRequest); }
@Override protected Object handleResumeOperation(final HttpRequest httpRequest, OperationDescription operationDescription, final SwaggerMethodParser methodParser, Type returnType) throws Exception { final Type operationStatusType = ((ParameterizedType) returnType).getActualTypeArguments()[0]; final TypeToken operationStatusTypeToken = TypeToken.of(operationStatusType); if (!operationStatusTypeToken.isSubtypeOf(OperationStatus.class)) { throw new InvalidReturnTypeException("AzureProxy only supports swagger interface methods that return Observable (such as " + methodParser.fullyQualifiedMethodName() + "()) if the Observable's inner type that is OperationStatus (not " + returnType.toString() + ")."); } PollStrategy.PollStrategyData pollStrategyData = (PollStrategy.PollStrategyData) operationDescription.pollStrategyData(); PollStrategy pollStrategy = pollStrategyData.initializeStrategy(this, methodParser); return pollStrategy.pollUntilDoneWithStatusUpdates(httpRequest, methodParser, operationStatusType); }
methodParser.fullyQualifiedMethodName(), methodParser.httpMethod(), operationDescription.url(), new HttpResponseDecoder(methodParser, serializer)); for (final String headerName : operationDescription.headers().keySet()) { request.withHeader(headerName, operationDescription.headers().get(headerName));
@Override public Object invoke(Object proxy, final Method method, Object[] args) { try { SwaggerMethodParser methodParser = null; HttpRequest request = null; if (method.isAnnotationPresent(ResumeOperation.class)) { OperationDescription opDesc = (OperationDescription) args[0]; Method resumeMethod = null; Method[] methods = method.getDeclaringClass().getMethods(); for (Method origMethod : methods) { if (origMethod.getName().equals(opDesc.methodName())) { resumeMethod = origMethod; break; } } methodParser = methodParser(resumeMethod); request = createHttpRequest(opDesc, methodParser, args); final Type returnType = methodParser.returnType(); return handleResumeOperation(request, opDesc, methodParser, returnType); } else { methodParser = methodParser(method); request = createHttpRequest(methodParser, args); final Single<HttpResponse> asyncResponse = sendHttpRequestAsync(request); final Type returnType = methodParser.returnType(); return handleAsyncHttpResponse(request, asyncResponse, methodParser, returnType); } } catch (Exception e) { throw Exceptions.propagate(e); } }