Esempio n. 1
0
        /// <summary>Schedule a request for execution.</summary>
        /// <remarks>Schedule a request for execution.</remarks>
        /// <?></?>
        /// <param name="request">request to execute</param>
        /// <param name="context">optional context; use null if not needed.</param>
        /// <param name="responseHandler">handler that will process the response.</param>
        /// <param name="callback">
        /// callback handler that will be called when the request is scheduled,
        /// started, completed, failed, or cancelled.
        /// </param>
        /// <returns>HttpAsyncClientFutureTask for the scheduled request.</returns>
        /// <exception cref="System.Exception">System.Exception</exception>
        public virtual HttpRequestFutureTask <T> Execute <T>(IHttpUriRequest request, HttpContext
                                                             context, ResponseHandler <T> responseHandler, FutureCallback <T> callback)
        {
            if (closed.Get())
            {
                throw new InvalidOperationException("Close has been called on this httpclient instance."
                                                    );
            }
            metrics.GetScheduledConnections().IncrementAndGet();
            HttpRequestTaskCallable <T> callable = new HttpRequestTaskCallable <T>(httpclient,
                                                                                   request, context, responseHandler, callback, metrics);
            HttpRequestFutureTask <T> httpRequestFutureTask = new HttpRequestFutureTask <T>(request
                                                                                            , callable);

            executorService.Execute(httpRequestFutureTask);
            return(httpRequestFutureTask);
        }
Esempio n. 2
0
 public HttpRequestFutureTask(IHttpUriRequest request, HttpRequestTaskCallable <V>
                              httpCallable) : base(httpCallable)
 {
     this.request  = request;
     this.callable = httpCallable;
 }