henriqueolliveira / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

HttpRequestFactory layer on top of HttpTransport for building requests in a common way #155

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
External references, such as a standards document, or specification?

N/A

Java environments (e.g. Java 6, Android 2.3, App Engine 1.4.2, or All)?

All

Please describe the feature requested.

We will add a new HttpRequestHandler interface that simply "handles" a request:

public interface HttpRequestHandler {
  void handle(HttpRequest request);
}

And then an HttpRequestFactory layer that is a thread-safe light-weight HTTP 
request factory layer on
top of the HTTP transport that has an optional HTTP request handler for 
initializing requests:

public abstract class HttpTransport {
  public final HttpRequestFactory createRequestFactory(HttpRequestHandler initializer);
}

public final class HttpRequestFactory {
  public HttpRequest buildRequest();
  public HttpRequest buildGetRequest();
  public HttpRequest buildGetRequest(GenericUrl url);
...
}

In this way we avoid the issue of complex thread safety issues by allowing a 
single HTTP request handler at initialization time.  Since an HTTP request is 
only managed by a single thread, we don't have to worry about maintaining 
global state.  It also avoids having to duplicate functionality between HTTP 
request and HTTP transport (which is currently used for maintaining 
functionality across all requests).

Original issue reported on code.google.com by yan...@google.com on 20 Mar 2011 at 2:58

GoogleCodeExporter commented 9 years ago
http://codereview.appspot.com/4287060

Original comment by yan...@google.com on 20 Mar 2011 at 3:02

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 20 Mar 2011 at 3:09

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 5 Apr 2011 at 7:36