|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.baidubce.AbstractBceClient
@ThreadSafe public abstract class AbstractBceClient
Abstract base class for BCE service clients.
Responsible for basic client capabilities that are the same across all BCE SDK Java clients (ex: setting the client endpoint).
Subclass names should be in the form of "com.baidubce.services.xxx.XxxClient", while "xxx" is the service ID and "Xxx" is the capitalized service ID.
Field Summary | |
---|---|
protected BceClientConfiguration |
config
The client configuration for this client. |
static String |
DEFAULT_CONTENT_TYPE
The default http request content type for all BCE service APIs. |
static String |
DEFAULT_ENCODING
The default string encoding for all BCE service APIs. |
static String |
DEFAULT_SERVICE_DOMAIN
The default service domain for BCE. |
static String |
URL_PREFIX
The common URL prefix for all BCE service APIs. |
Constructor Summary | |
---|---|
AbstractBceClient(BceClientConfiguration config,
HttpResponseHandler[] responseHandlers)
Equivalent to AbstractBceClient(config, responseHandlers, false) |
|
AbstractBceClient(BceClientConfiguration config,
HttpResponseHandler[] responseHandlers,
boolean isHttpAsyncPutEnabled)
Constructs a new AbstractBceClient with the specified client configuration and handlers. |
Method Summary | ||
---|---|---|
BceHttpClient |
getClient()
|
|
URI |
getEndpoint()
Returns the service endpoint to which this client will send requests. |
|
String |
getServiceId()
Returns the target service ID. |
|
protected
|
invokeHttpClient(InternalRequest request,
Class<T> responseClass)
Subclasses should invoke this method for sending request to the target service. |
|
boolean |
isRegionSupported()
Returns true if the target service supports regions. |
|
void |
setClient(BceHttpClient client)
|
|
void |
shutdown()
Shuts down the client and releases all underlying resources. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_SERVICE_DOMAIN
public static final String URL_PREFIX
public static final String DEFAULT_ENCODING
public static final String DEFAULT_CONTENT_TYPE
protected BceClientConfiguration config
Constructor Detail |
---|
public AbstractBceClient(BceClientConfiguration config, HttpResponseHandler[] responseHandlers, boolean isHttpAsyncPutEnabled)
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. See
BceHttpClient.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.public AbstractBceClient(BceClientConfiguration config, HttpResponseHandler[] responseHandlers)
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. See
BceHttpClient.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.Method Detail |
---|
public boolean isRegionSupported()
The result will impact the construction of default service endpoint.
public URI getEndpoint()
public String getServiceId()
public BceHttpClient getClient()
public void setClient(BceHttpClient client)
public void shutdown()
Invoking this method is NOT a must. Once it is called, no subsequent requests should be made.
protected <T extends AbstractBceResponse> T invokeHttpClient(InternalRequest request, Class<T> responseClass)
This method will add "Content-Type" and "Date" to headers with default values if not present.
T
- the type of responserequest
- the request to build up the HTTP request.responseClass
- the response class.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |