com.google.api.client.googleapis.json
Class GoogleJsonRpcHttpTransport

java.lang.Object
  extended by com.google.api.client.googleapis.json.GoogleJsonRpcHttpTransport

public final class GoogleJsonRpcHttpTransport
extends Object

JSON-RPC 2.0 HTTP transport for RPC requests for Google API's, including both singleton and batched requests.

This implementation is thread-safe, as long as you don't change the values of the public fields after construction. These fields are deprecated for this reason.

Warning: this is based on an undocumented experimental Google functionality that may stop working or change in behavior at any time. Beware of this risk if running this in production code.

Since:
1.3
Author:
Yaniv Inbar

Nested Class Summary
static class GoogleJsonRpcHttpTransport.Builder
          GoogleJsonRpcHttpTransport Builder.
 
Field Summary
 String accept
          Deprecated. (scheduled to be made private final in 1.11) Use GoogleJsonRpcHttpTransport.Builder.setAccept(String).
 String contentType
          Deprecated. (scheduled to be made private final in 1.11) Use GoogleJsonRpcHttpTransport.Builder.setContentType(String).
 JsonFactory jsonFactory
          Deprecated. (scheduled to be made private final in 1.11) Use GoogleJsonRpcHttpTransport.Builder.
 GenericUrl rpcServerUrl
          Deprecated. (scheduled to be made private final in 1.11) Use GoogleJsonRpcHttpTransport.Builder.setRpcServerUrl(GenericUrl).
 HttpTransport transport
          Deprecated. (scheduled to be made private final in 1.11) Use GoogleJsonRpcHttpTransport.Builder.
 
Constructor Summary
  GoogleJsonRpcHttpTransport(HttpTransport httpTransport, JsonFactory jsonFactory)
          Creates a new GoogleJsonRpcHttpTransport with default values for RPC server, and Content type and Accept headers.
protected GoogleJsonRpcHttpTransport(HttpTransport httpTransport, JsonFactory jsonFactory, String rpcServerUrl, String mimeType, String accept)
          Creates a new GoogleJsonRpcHttpTransport.
 
Method Summary
 HttpRequest buildPostRequest(JsonRpcRequest request)
          Builds a POST HTTP request for the JSON-RPC requests objects specified in the given JSON-RPC request object.
 HttpRequest buildPostRequest(List<JsonRpcRequest> requests)
          Builds a POST HTTP request for the JSON-RPC requests objects specified in the given JSON-RPC request objects.
 String getAccept()
          Returns the Accept header used for requests.
 String getContentType()
          Deprecated. (scheduled to be removed in 1.11) Use getMimeType() instead.
 HttpTransport getHttpTransport()
          Returns the HTTP transport used for building requests.
 JsonFactory getJsonFactory()
          Returns the JSON factory used for building requests.
 String getMimeType()
          Returns the MIME type header used for requests.
 String getRpcServerUrl()
          Returns the RPC server URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rpcServerUrl

@Deprecated
public GenericUrl rpcServerUrl
Deprecated. (scheduled to be made private final in 1.11) Use GoogleJsonRpcHttpTransport.Builder.setRpcServerUrl(GenericUrl).
RPC server URL.


transport

@Deprecated
public HttpTransport transport
Deprecated. (scheduled to be made private final in 1.11) Use GoogleJsonRpcHttpTransport.Builder.
(REQUIRED) HTTP transport required for building requests.


jsonFactory

@Deprecated
public JsonFactory jsonFactory
Deprecated. (scheduled to be made private final in 1.11) Use GoogleJsonRpcHttpTransport.Builder.
(REQUIRED) JSON factory to use for building requests.


contentType

@Deprecated
public String contentType
Deprecated. (scheduled to be made private final in 1.11) Use GoogleJsonRpcHttpTransport.Builder.setContentType(String).
Content type header to use for requests. By default this is "application/json-rpc".


accept

@Deprecated
public String accept
Deprecated. (scheduled to be made private final in 1.11) Use GoogleJsonRpcHttpTransport.Builder.setAccept(String).
Accept header to use for requests. By default this is "application/json-rpc".

Constructor Detail

GoogleJsonRpcHttpTransport

public GoogleJsonRpcHttpTransport(HttpTransport httpTransport,
                                  JsonFactory jsonFactory)
Creates a new GoogleJsonRpcHttpTransport with default values for RPC server, and Content type and Accept headers.

Parameters:
httpTransport - HTTP transport required for building requests.
jsonFactory - JSON factory to use for building requests.
Since:
1.9

GoogleJsonRpcHttpTransport

protected GoogleJsonRpcHttpTransport(HttpTransport httpTransport,
                                     JsonFactory jsonFactory,
                                     String rpcServerUrl,
                                     String mimeType,
                                     String accept)
Creates a new GoogleJsonRpcHttpTransport.

Parameters:
httpTransport - HTTP transport required for building requests.
jsonFactory - JSON factory to use for building requests.
rpcServerUrl - RPC server URL.
mimeType - Content type header to use for requests.
accept - Accept header to use for requests.
Since:
1.9
Method Detail

getHttpTransport

public final HttpTransport getHttpTransport()
Returns the HTTP transport used for building requests.

Since:
1.9

getJsonFactory

public final JsonFactory getJsonFactory()
Returns the JSON factory used for building requests.

Since:
1.9

getRpcServerUrl

public final String getRpcServerUrl()
Returns the RPC server URL.

Since:
1.9

getContentType

@Deprecated
public final String getContentType()
Deprecated. (scheduled to be removed in 1.11) Use getMimeType() instead.

Returns the Content type header used for requests.

Since:
1.9

getMimeType

public final String getMimeType()
Returns the MIME type header used for requests.

Since:
1.10

getAccept

public final String getAccept()
Returns the Accept header used for requests.

Since:
1.9

buildPostRequest

public HttpRequest buildPostRequest(JsonRpcRequest request)
Builds a POST HTTP request for the JSON-RPC requests objects specified in the given JSON-RPC request object.

You may use JsonFactory.createJsonParser(java.io.InputStream) to get the JsonParser, and JsonParser.parseAndClose(Class, CustomizeJsonParser).

Parameters:
request - JSON-RPC request object
Returns:
HTTP request

buildPostRequest

public HttpRequest buildPostRequest(List<JsonRpcRequest> requests)
Builds a POST HTTP request for the JSON-RPC requests objects specified in the given JSON-RPC request objects.

Note that the request will always use batching -- i.e. JSON array of requests -- even if there is only one request. You may use JsonFactory.createJsonParser(java.io.InputStream) to get the JsonParser, and JsonParser.parseArrayAndClose(Collection, Class, CustomizeJsonParser) .

Parameters:
requests - JSON-RPC request objects
Returns:
HTTP request


Copyright © 2010-2012 Google. All Rights Reserved.