CHJani / google-api-java-client

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

Move code from generated libraries into the base library #345

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

Implement the design proposal here:
http://codereview.appspot.com/5080054/

1. Add RemoteRequestInitializer that will be used to initialize requests. E.g 
for setting global parameters.

SampleUsage:

class BooksRemoteRequestInitializer implements RemoteRequestInitializer {

  public void initialize(GoogleRequest request) {
    BooksRequest booksRequest = (BooksRequest)request;
    booksRequest.setPrettyPrint(true);
    booksRequest.setKey(ClientCredentials.KEY);
  }
}

2. Move as much as possible of the reusable code across the generated
libraries.
Specifically includes the common parts of ApiClient and RemoteRequest.

Example:

final Books books = new Books(new NetHttpTransport(), jsonFactory);
books.setApplicationName("Google-BooksSample/1.0");
books.setKey(ClientCredentials.KEY);

Now becomes:

final Books books = Books.builder(new NetHttpTransport(), jsonFactory)
    .setApplicationName("Google-BooksSample/1.0")
    .setRemoteRequestInitializer(new BooksRemoteRequestInitializer())
    .build();

3. Follow our thread-safety style guidelines.

Original issue reported on code.google.com by rmis...@google.com on 4 Nov 2011 at 3:49

GoogleCodeExporter commented 9 years ago
Fixed in:
http://codereview.appspot.com/5271052/
http://codereview.appspot.com/5225041/

Original comment by rmis...@google.com on 4 Nov 2011 at 3:50

GoogleCodeExporter commented 9 years ago

Original comment by rmis...@google.com on 4 Nov 2011 at 4:02