public abstract class AmazonWebServiceClient extends Object
Responsible for basic client capabilities that are the same across all AWS SDK Java clients (ex: setting the client endpoint).
Modifier and Type | Field and Description |
---|---|
protected AmazonHttpClient |
client
Low level client for sending requests to AWS services.
|
protected ClientConfiguration |
clientConfiguration
The client configuration
|
protected URI |
endpoint
The service endpoint to which this client will send requests.
|
static boolean |
LOGGING_AWS_REQUEST_METRIC
Deprecated.
No longer used.
|
protected List<RequestHandler2> |
requestHandler2s
Optional request handlers for additional request processing.
|
protected int |
timeOffset
Optional offset (in seconds) to use when signing requests
|
Modifier | Constructor and Description |
---|---|
protected |
AmazonWebServiceClient(AwsSyncClientParams clientParams) |
|
AmazonWebServiceClient(ClientConfiguration clientConfiguration)
Constructs a new AmazonWebServiceClient object using the specified
configuration.
|
|
AmazonWebServiceClient(ClientConfiguration clientConfiguration,
RequestMetricCollector requestMetricCollector)
Constructs a new AmazonWebServiceClient object using the specified
configuration and request metric collector.
|
protected |
AmazonWebServiceClient(ClientConfiguration clientConfiguration,
RequestMetricCollector requestMetricCollector,
boolean disableStrictHostNameVerification) |
Modifier and Type | Method and Description |
---|---|
void |
addRequestHandler(RequestHandler requestHandler)
Deprecated.
by
addRequestHandler(RequestHandler2) .
Appends a request handler to the list of registered handlers that are run
as part of a request's lifecycle. |
void |
addRequestHandler(RequestHandler2 requestHandler2)
Deprecated.
|
protected <T extends AmazonWebServiceRequest> |
beforeClientExecution(T request)
Notify request handlers that we are about to start execution.
|
protected <T extends AmazonWebServiceRequest> |
beforeMarshalling(T request)
Runs the
beforeMarshalling method of any
RequestHandler2 s associated with this client. |
protected boolean |
calculateCRC32FromCompressedData()
Hook to allow clients to override CRC32 calculation behavior.
|
protected void |
checkMutability()
If the client has been marked as immutable then throw an
UnsupportedOperationException , otherwise do nothing. |
void |
configureRegion(Regions region)
Deprecated.
|
protected ExecutionContext |
createExecutionContext(AmazonWebServiceRequest req) |
protected ExecutionContext |
createExecutionContext(AmazonWebServiceRequest req,
com.amazonaws.internal.auth.SignerProvider signerProvider) |
protected ExecutionContext |
createExecutionContext(Request<?> req) |
protected com.amazonaws.internal.auth.SignerProvider |
createSignerProvider(Signer signer) |
protected void |
endClientExecution(AWSRequestMetrics awsRequestMetrics,
Request<?> request,
Response<?> response)
Convenient method to end the client execution without logging the
awsRequestMetrics.
|
protected void |
endClientExecution(AWSRequestMetrics awsRequestMetrics,
Request<?> request,
Response<?> response,
boolean loggingAwsRequestMetrics)
Common routine to end a client AWS request/response execution and collect
the request metrics.
|
String |
getEndpointPrefix() |
RequestMetricCollector |
getRequestMetricsCollector()
Returns the client specific
RequestMetricCollector ; or null if
there is none. |
protected String |
getServiceAbbreviation()
Deprecated.
by
getServiceName() . |
String |
getServiceName()
Returns the service abbreviation for this service, used for identifying
service endpoints by region, identifying the necessary signer, etc.
|
protected String |
getServiceNameIntern()
Internal method for implementing
getServiceName() . |
protected Signer |
getSigner()
Deprecated.
|
Signer |
getSignerByURI(URI uri)
Returns the signer based on the given URI and the current AWS client
configuration.
|
String |
getSignerOverride() |
protected com.amazonaws.internal.auth.SignerProvider |
getSignerProvider() |
String |
getSignerRegionOverride()
Returns the signer region override.
|
int |
getTimeOffset()
Returns the optional value for time offset for this client.
|
protected static boolean |
isProfilingEnabled() |
protected boolean |
isRequestMetricsEnabled(AmazonWebServiceRequest req)
Returns true if request metric collection is applicable to the given
request; false otherwise.
|
void |
makeImmutable()
Deprecated.
|
void |
removeRequestHandler(RequestHandler requestHandler)
Deprecated.
|
void |
removeRequestHandler(RequestHandler2 requestHandler2)
Deprecated.
|
protected RequestMetricCollector |
requestMetricCollector()
Returns the client specific request metric collector if there is one; or
the one at the AWS SDK level otherwise.
|
void |
setEndpoint(String endpoint)
Deprecated.
use
AwsClientBuilder.setEndpointConfiguration(AwsClientBuilder.EndpointConfiguration) for example:
builder.setEndpointConfiguration(new EndpointConfiguration(endpoint, signingRegion)); |
protected void |
setEndpointPrefix(String endpointPrefix)
An internal method used to explicitly override the service name for region metadata.
|
void |
setRegion(Region region)
Deprecated.
|
void |
setServiceNameIntern(String serviceName)
An internal method used to explicitly override the service name
computed by the default implementation.
|
void |
setSignerRegionOverride(String signerRegionOverride)
An internal method used to explicitly override the internal signer region
computed by the default implementation.
|
void |
setTimeOffset(int timeOffset)
Sets the optional value for time offset for this client.
|
void |
shutdown()
Shuts down this client object, releasing any resources that might be held
open.
|
protected boolean |
useStrictHostNameVerification()
Hook to allow S3 client to disable strict hostname verification since it uses wildcard
certificates.
|
<T extends AmazonWebServiceClient> |
withEndpoint(String endpoint)
Deprecated.
use
AwsClientBuilder.withEndpointConfiguration(AwsClientBuilder.EndpointConfiguration) for example:
AmazonSNSClientBuilder.standard().withEndpointConfiguration(new EndpointConfiguration(endpoint, signingRegion)).build(); |
<T extends AmazonWebServiceClient> |
withRegion(Region region)
Deprecated.
use
AwsClientBuilder.withRegion(Region) for example:
AmazonSNSClientBuilder.standard().withRegion(region).build(); |
<T extends AmazonWebServiceClient> |
withRegion(Regions region)
Deprecated.
use
AwsClientBuilder.withRegion(Regions) for example:
AmazonSNSClientBuilder.standard().withRegion(region).build(); |
AmazonWebServiceClient |
withTimeOffset(int timeOffset)
Sets the optional value for time offset for this client.
|
@Deprecated public static final boolean LOGGING_AWS_REQUEST_METRIC
protected volatile URI endpoint
Subclass should only read but not assign to this field, at least not without synchronization on the enclosing object for thread-safety reason.
protected ClientConfiguration clientConfiguration
protected AmazonHttpClient client
protected final List<RequestHandler2> requestHandler2s
protected int timeOffset
public AmazonWebServiceClient(ClientConfiguration clientConfiguration)
clientConfiguration
- The client configuration for this client.public AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector)
clientConfiguration
- The client configuration for this client.requestMetricCollector
- optional request metric collector to be used at the http
client level; can be null.protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification)
protected AmazonWebServiceClient(AwsSyncClientParams clientParams)
@Deprecated protected Signer getSigner()
Note, however, the signer configured for S3 is incomplete at this stage as the information on the S3 bucket and key is not yet known.
protected com.amazonaws.internal.auth.SignerProvider getSignerProvider()
@Deprecated public void setEndpoint(String endpoint) throws IllegalArgumentException
AwsClientBuilder.setEndpointConfiguration(AwsClientBuilder.EndpointConfiguration)
for example:
builder.setEndpointConfiguration(new EndpointConfiguration(endpoint, signingRegion));
This method is not threadsafe. Endpoints should be configured when the client is created and before any service requests are made. Changing it afterwards creates inevitable race conditions for any service requests in transit.
Callers can pass in just the endpoint (ex: "ec2.amazonaws.com") or a full
URL, including the protocol (ex: "https://ec2.amazonaws.com"). If the
protocol is not specified here, the default protocol from this client's
ClientConfiguration
will be used, which by default is HTTPS.
For more information on using AWS regions with the AWS SDK for Java, and a complete list of all available endpoints for all AWS services, see: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=3912
endpoint
- The endpoint (ex: "ec2.amazonaws.com") or a full URL,
including the protocol (ex: "https://ec2.amazonaws.com") of
the region specific AWS endpoint this client will communicate
with.IllegalArgumentException
- If any problems are detected with the specified endpoint.public Signer getSignerByURI(URI uri)
Note, however, the signer returned for S3 is incomplete at this stage as the information on the S3 bucket and key is not yet known.
@Deprecated public void setRegion(Region region) throws IllegalArgumentException
AwsClientBuilder.setRegion(String)
setEndpoint(String)
, sets the regional
endpoint for this client's service calls. Callers can use this method to control which AWS
region they want to work with.
This method is not threadsafe. A region should be configured when the client is created and before any service requests are made. Changing it afterwards creates inevitable race conditions for any service requests in transit or retrying.
By default, all service endpoints in all regions use the https protocol. To use http instead,
specify it in the ClientConfiguration
supplied at construction.
region
- The region this client will communicate with. See
Region.getRegion(com.amazonaws.regions.Regions)
for accessing a given
region.IllegalArgumentException
- If the given region is null, or if this service isn't available in the given
region. See Region.isServiceSupported(String)
Region.getRegion(com.amazonaws.regions.Regions)
,
Region.createClient(Class, com.amazonaws.auth.AWSCredentialsProvider,
ClientConfiguration)
@Deprecated public final void configureRegion(Regions region)
AwsClientBuilder.setRegion(String)
region
- region to set to; must not be null.setRegion(Region)
public void shutdown()
@Deprecated public void addRequestHandler(RequestHandler requestHandler)
addRequestHandler(RequestHandler2)
.
Appends a request handler to the list of registered handlers that are run
as part of a request's lifecycle.requestHandler
- The new handler to add to the current list of request
handlers.@Deprecated public void addRequestHandler(RequestHandler2 requestHandler2)
AwsClientBuilder.withRequestHandlers(RequestHandler2...)
requestHandler2
- The new handler to add to the current list of request
handlers.@Deprecated public void removeRequestHandler(RequestHandler requestHandler)
AwsClientBuilder.withRequestHandlers(RequestHandler2...)
requestHandler
- The handler to remove from the current list of request
handlers.@Deprecated public void removeRequestHandler(RequestHandler2 requestHandler2)
AwsClientBuilder.withRequestHandlers(RequestHandler2...)
protected final <T extends AmazonWebServiceRequest> T beforeMarshalling(T request)
beforeMarshalling
method of any
RequestHandler2
s associated with this client.request
- the request passed in from the userprotected ExecutionContext createExecutionContext(AmazonWebServiceRequest req)
protected ExecutionContext createExecutionContext(AmazonWebServiceRequest req, com.amazonaws.internal.auth.SignerProvider signerProvider)
protected final ExecutionContext createExecutionContext(Request<?> req)
protected com.amazonaws.internal.auth.SignerProvider createSignerProvider(Signer signer)
protected static boolean isProfilingEnabled()
protected final boolean isRequestMetricsEnabled(AmazonWebServiceRequest req)
public void setTimeOffset(int timeOffset)
timeOffset
- The optional value for time offset (in seconds) for this client.public AmazonWebServiceClient withTimeOffset(int timeOffset)
timeOffset
- The optional value for time offset (in seconds) for this client.public int getTimeOffset()
public RequestMetricCollector getRequestMetricsCollector()
RequestMetricCollector
; or null if
there is none.protected RequestMetricCollector requestMetricCollector()
protected final <T extends AmazonWebServiceRequest> T beforeClientExecution(T request)
protected final void endClientExecution(AWSRequestMetrics awsRequestMetrics, Request<?> request, Response<?> response)
protected final void endClientExecution(AWSRequestMetrics awsRequestMetrics, Request<?> request, Response<?> response, @Deprecated boolean loggingAwsRequestMetrics)
AWSRequestMetrics.Field.ClientExecuteTime
and call this method
in a try-finally block.loggingAwsRequestMetrics
- deprecated and ignored@Deprecated protected String getServiceAbbreviation()
getServiceName()
.public String getServiceName()
public String getEndpointPrefix()
protected void setEndpointPrefix(String endpointPrefix)
protected String getServiceNameIntern()
getServiceName()
. Method is
protected by intent so peculiar subclass that don't follow the class
naming convention can choose to return whatever service name as needed.public final void setServiceNameIntern(String serviceName)
public final String getSignerRegionOverride()
setSignerRegionOverride(String).
public final void setSignerRegionOverride(String signerRegionOverride)
@Deprecated public <T extends AmazonWebServiceClient> T withRegion(Region region)
AwsClientBuilder.withRegion(Region)
for example:
AmazonSNSClientBuilder.standard().withRegion(region).build();
setRegion(Region)
.
Example: AmazonDynamoDBClient client = new AmazonDynamoDBClient(...).withRegion(...);
setRegion(Region)
@Deprecated public <T extends AmazonWebServiceClient> T withRegion(Regions region)
AwsClientBuilder.withRegion(Regions)
for example:
AmazonSNSClientBuilder.standard().withRegion(region).build();
region
- region to set to; must not be null.withRegion(Region)
@Deprecated public <T extends AmazonWebServiceClient> T withEndpoint(String endpoint)
AwsClientBuilder.withEndpointConfiguration(AwsClientBuilder.EndpointConfiguration)
for example:
AmazonSNSClientBuilder.standard().withEndpointConfiguration(new EndpointConfiguration(endpoint, signingRegion)).build();
setEndpoint(String)
.
Example: AmazonDynamoDBClient client = new AmazonDynamoDBClient(...).withEndPoint(...);
setEndpoint(String)
@Deprecated public final void makeImmutable()
protected final void checkMutability()
UnsupportedOperationException
, otherwise do nothing. Should be called by each mutating
method.protected boolean useStrictHostNameVerification()
protected boolean calculateCRC32FromCompressedData()
public String getSignerOverride()
Copyright © 2017. All rights reserved.