com.amazonaws
Class AmazonWebServiceClient

java.lang.Object
  extended by com.amazonaws.AmazonWebServiceClient
Direct Known Subclasses:
AmazonAutoScalingClient, AmazonCloudWatchClient, AmazonDynamoDBClient, AmazonEC2Client, AmazonElasticLoadBalancingClient, AmazonS3Client, AmazonSimpleDBClient, AmazonSimpleEmailServiceClient, AmazonSNSClient, AmazonSQSClient

public abstract class AmazonWebServiceClient
extends java.lang.Object

Abstract base class for Amazon Web Service Java clients.

Responsible for basic client capabilities that are the same across all AWS SDK Java clients (ex: setting the client endpoint).


Field Summary
static boolean LOGGING_AWS_REQUEST_METRIC
           
 
Constructor Summary
AmazonWebServiceClient(ClientConfiguration clientConfiguration)
          Constructs a new AmazonWebServiceClient object using the specified configuration.
AmazonWebServiceClient(ClientConfiguration clientConfiguration, com.amazonaws.metrics.RequestMetricCollector requestMetricCollector)
          Constructs a new AmazonWebServiceClient object using the specified configuration and request metric collector.
 
Method Summary
 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)
          Appends a request handler to the list of registered handlers that are run as part of a request's lifecycle.
 com.amazonaws.metrics.RequestMetricCollector getRequestMetricsCollector()
          Returns the client specific RequestMetricCollector; or null if there is none.
 java.lang.String getServiceName()
          Returns the service abbreviation for this service, used for identifying service endpoints by region, identifying the necessary signer, etc.
 Signer getSignerByURI(java.net.URI uri)
          Returns the signer based on the given URI and the current AWS client configuration.
 java.lang.String getSignerRegionOverride()
          Returns the signer region override.
 int getTimeOffset()
          Returns the optional value for time offset for this client.
 void removeRequestHandler(RequestHandler requestHandler)
          Removes a request handler from the list of registered handlers that are run as part of a request's lifecycle.
 void removeRequestHandler(RequestHandler2 requestHandler2)
           
 void setConfiguration(ClientConfiguration clientConfiguration)
          Deprecated. by client configuration via the constructor. This method will be removed later on.
 void setEndpoint(java.lang.String endpoint)
          Overrides the default endpoint for this client.
 void setEndpoint(java.lang.String endpoint, java.lang.String serviceName, java.lang.String regionId)
          Deprecated.  
 void setRegion(Region region)
          An alternative to setEndpoint(String), sets the regional endpoint for this client's service calls.
 void setServiceNameIntern(java.lang.String serviceName)
          An internal method used to explicitly override the service name computed by the default implementation.
 void setSignerRegionOverride(java.lang.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.
 AmazonWebServiceClient withTimeOffset(int timeOffset)
          Sets the optional value for time offset for this client.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGING_AWS_REQUEST_METRIC

public static final boolean LOGGING_AWS_REQUEST_METRIC
See Also:
Constant Field Values
Constructor Detail

AmazonWebServiceClient

public AmazonWebServiceClient(ClientConfiguration clientConfiguration)
Constructs a new AmazonWebServiceClient object using the specified configuration.

Parameters:
clientConfiguration - The client configuration for this client.

AmazonWebServiceClient

public AmazonWebServiceClient(ClientConfiguration clientConfiguration,
                              com.amazonaws.metrics.RequestMetricCollector requestMetricCollector)
Constructs a new AmazonWebServiceClient object using the specified configuration and request metric collector.

Parameters:
clientConfiguration - The client configuration for this client.
requestMetricCollector - optional request metric collector to be used at the http client level; can be null.
Method Detail

setEndpoint

public void setEndpoint(java.lang.String endpoint)
                 throws java.lang.IllegalArgumentException
Overrides the default endpoint for this client. Callers can use this method to control which AWS region they want to work with.

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

Parameters:
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.
Throws:
java.lang.IllegalArgumentException - If any problems are detected with the specified endpoint.

setEndpoint

@Deprecated
public void setEndpoint(java.lang.String endpoint,
                                   java.lang.String serviceName,
                                   java.lang.String regionId)
Deprecated. 

An internal method that is not expected to be normally called except for AWS internal development purposes.

Overrides the default endpoint for this client ("http://dynamodb.us-east-1.amazonaws.com/") and explicitly provides an AWS region ID and AWS service name to use when the client calculates a signature for requests. In almost all cases, this region ID and service name are automatically determined from the endpoint, and callers should use the simpler one-argument form of setEndpoint instead of this method.

Callers can pass in just the endpoint (ex: "dynamodb.us-east-1.amazonaws.com/") or a full URL, including the protocol (ex: "http://dynamodb.us-east-1.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

Parameters:
endpoint - The endpoint (ex: "dynamodb.us-east-1.amazonaws.com/") or a full URL, including the protocol (ex: "http://dynamodb.us-east-1.amazonaws.com/") of the region specific AWS endpoint this client will communicate with.
serviceName - This parameter is ignored.
regionId - The ID of the region in which this service resides AND the overriding region for signing purposes.
Throws:
java.lang.IllegalArgumentException - If any problems are detected with the specified endpoint.

getSignerByURI

public Signer getSignerByURI(java.net.URI uri)
Returns the signer based on the given URI and the current AWS client configuration. Currently only the SQS client can have different region on a per request basis. For other AWS clients, the region remains the same on a per AWS client level.

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.


setRegion

public void setRegion(Region region)
               throws java.lang.IllegalArgumentException
An alternative to 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.

Parameters:
region - The region this client will communicate with. See Region.getRegion(com.amazonaws.regions.Regions) for accessing a given region.
Throws:
java.lang.IllegalArgumentException - If the given region is null, or if this service isn't available in the given region. See Region.isServiceSupported(String)
See Also:
Region.getRegion(com.amazonaws.regions.Regions), Region.createClient(Class, com.amazonaws.auth.AWSCredentialsProvider, ClientConfiguration)

setConfiguration

@Deprecated
public void setConfiguration(ClientConfiguration clientConfiguration)
Deprecated. by client configuration via the constructor. This method will be removed later on.


shutdown

public void shutdown()
Shuts down this client object, releasing any resources that might be held open. This is an optional method, and callers are not expected to call it, but can if they want to explicitly release any open resources. Once a client has been shutdown, it should not be used to make any more requests.


addRequestHandler

@Deprecated
public 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.

Parameters:
requestHandler - The new handler to add to the current list of request handlers.

addRequestHandler

public void addRequestHandler(RequestHandler2 requestHandler2)
Appends a request handler to the list of registered handlers that are run as part of a request's lifecycle.

Parameters:
requestHandler2 - The new handler to add to the current list of request handlers.

removeRequestHandler

public void removeRequestHandler(RequestHandler requestHandler)
Removes a request handler from the list of registered handlers that are run as part of a request's lifecycle.

Parameters:
requestHandler - The handler to remove from the current list of request handlers.

removeRequestHandler

public void removeRequestHandler(RequestHandler2 requestHandler2)

setTimeOffset

public void setTimeOffset(int timeOffset)
Sets the optional value for time offset for this client. This value will be applied to all requests processed through this client. Value is in seconds, positive values imply the current clock is "fast", negative values imply clock is slow.

Parameters:
timeOffset - The optional value for time offset (in seconds) for this client.

withTimeOffset

public AmazonWebServiceClient withTimeOffset(int timeOffset)
Sets the optional value for time offset for this client. This value will be applied to all requests processed through this client. Value is in seconds, positive values imply the current clock is "fast", negative values imply clock is slow.

Parameters:
timeOffset - The optional value for time offset (in seconds) for this client.
Returns:
the updated web service client

getTimeOffset

public int getTimeOffset()
Returns the optional value for time offset for this client. This value will be applied to all requests processed through this client. Value is in seconds, positive values imply the current clock is "fast", negative values imply clock is slow.

Returns:
The optional value for time offset (in seconds) for this client.

getRequestMetricsCollector

public com.amazonaws.metrics.RequestMetricCollector getRequestMetricsCollector()
Returns the client specific RequestMetricCollector; or null if there is none.


getServiceName

public java.lang.String getServiceName()
Returns the service abbreviation for this service, used for identifying service endpoints by region, identifying the necessary signer, etc. Used to be call "getServiceAbbreviation".


setServiceNameIntern

public final void setServiceNameIntern(java.lang.String serviceName)
An internal method used to explicitly override the service name computed by the default implementation. This method is not expected to be normally called except for AWS internal development purposes.


getSignerRegionOverride

public final java.lang.String getSignerRegionOverride()
Returns the signer region override.

See Also:
setSignerRegionOverride(String).

setSignerRegionOverride

public final void setSignerRegionOverride(java.lang.String signerRegionOverride)
An internal method used to explicitly override the internal signer region computed by the default implementation. This method is not expected to be normally called except for AWS internal development purposes.



Copyright © 2010 Amazon Web Services, Inc. All Rights Reserved.