类 AbstractMochowClient
java.lang.Object
com.baidu.mochow.client.AbstractMochowClient
- 直接已知子类:
MochowClient
Abstract base class for Mochow service client.
-
字段概要
字段修饰符和类型字段说明protected ClientConfigurationThe client configuration for this client.static final StringThe default http request content type for all Mochow service APIs.static final StringThe default string encoding for all Mochow service APIs.static final StringThe default service domain for Mochow.static final StringThe common URL prefix for all Mochow service APIs. -
构造器概要
构造器构造器说明AbstractMochowClient(ClientConfiguration config, HttpResponseHandler[] responseHandlers) Equivalent to AbstractBceClient(config, responseHandlers, false)AbstractMochowClient(ClientConfiguration config, HttpResponseHandler[] responseHandlers, boolean isHttpAsyncPutEnabled) Constructs a new AbstractBceClient with the specified client configuration and handlers. -
方法概要
修饰符和类型方法说明protected <T extends AbstractMochowResponse>
TinvokeHttpClient(InternalRequest request, Class<T> responseClass) Subclasses should invoke this method for sending request to the target service.voidshutdown()Shuts down the client and releases all underlying resources.
-
字段详细资料
-
DEFAULT_SERVICE_DOMAIN
The default service domain for Mochow.- 另请参阅:
-
URL_PREFIX
The common URL prefix for all Mochow service APIs.- 另请参阅:
-
DEFAULT_ENCODING
The default string encoding for all Mochow service APIs.- 另请参阅:
-
DEFAULT_CONTENT_TYPE
The default http request content type for all Mochow service APIs.- 另请参阅:
-
config
The client configuration for this client.
-
-
构造器详细资料
-
AbstractMochowClient
public AbstractMochowClient(ClientConfiguration config, HttpResponseHandler[] responseHandlers, boolean isHttpAsyncPutEnabled) Constructs a new AbstractBceClient with the specified client configuration and handlers.The constructor will extract serviceId from the class name automatically. And if there is no endpoint specified in the client configuration, the constructor will create a default one.
- 参数:
config- the client configuration. The constructor makes a copy of this parameter so that it is safe to change the configuration after then.responseHandlers- a list of handlers for processing HTTP responses from services. SeeHttpClient.execute(InternalRequest, Class, HttpResponseHandler[])isHttpAsyncPutEnabled- whether or not PUT method use Async manner.- 抛出:
IllegalStateException- if the class name does not follow the naming convention for BCE clients.IllegalArgumentException- if the endpoint specified in the client configuration is not a valid URI.
-
AbstractMochowClient
Equivalent to AbstractBceClient(config, responseHandlers, false)- 参数:
config- the client configuration. The constructor makes a copy of this parameter so that it is safe to change the configuration after then.responseHandlers- a list of handlers for processing HTTP responses from services. SeeHttpClient.execute(InternalRequest, Class, HttpResponseHandler[])- 抛出:
IllegalStateException- if the class name does not follow the naming convention for BCE clients.IllegalArgumentException- if the endpoint specified in the client configuration is not a valid URI.
-
-
方法详细资料
-
shutdown
public void shutdown()Shuts down the client and releases all underlying resources.Invoking this method is NOT a must. Once it is called, no subsequent requests should be made.
-
invokeHttpClient
protected <T extends AbstractMochowResponse> T invokeHttpClient(InternalRequest request, Class<T> responseClass) Subclasses should invoke this method for sending request to the target service.This method will add "Content-Type" and "Date" to headers with default values if not present.
- 类型参数:
T- the type of response- 参数:
request- the request to build up the HTTP request.responseClass- the response class.- 返回:
- the final response object.
-