Class S3ClientCache
- java.lang.Object
-
- com.amazonaws.services.dynamodbv2.datamodeling.S3ClientCache
-
public class S3ClientCache extends Object
A smart Map forAmazonS3objects.S3ClientCachekeeps the clients organized by region, and if providedAWSCredentialswill create clients on the fly. Otherwise it just return clients given to it withuseClient(AmazonS3).
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AmazonS3getClient(Region s3region)Returns a client for the requested region, or throws an exception when unable.TransferManagergetTransferManager(Region region)Returns aTransferManagerfor the given region, or throws an exception when unable.voiduseClient(AmazonS3 client)Force the client cache to provide a certain client for the region which that client is configured.
-
-
-
Method Detail
-
useClient
public void useClient(AmazonS3 client)
Force the client cache to provide a certain client for the region which that client is configured. This can be useful to provide clients with differentS3ClientOptionsor use aAmazonS3EncryptionClientin place of a regular client. Using a new client will also forcibly shut down anyTransferManagerthat has been instantiated with that client, with theTransferManager.shutdownNow()method.- Parameters:
client- AnAmazonS3to use in the cache. Its region will be detected automatically.
-
getClient
public AmazonS3 getClient(Region s3region)
Returns a client for the requested region, or throws an exception when unable.- Parameters:
s3region- The region the returnedAmazonS3will be configured to use.- Returns:
- A client for the given region from the cache, either instantiated
automatically from the provided
AWSCredentialsor provided withuseClient(AmazonS3). - Throws:
IllegalArgumentException- When a region is requested that has not been provided to the cache withuseClient(AmazonS3), and the cache has noAWSCredentialswith which a client may be instantiated.
-
getTransferManager
public TransferManager getTransferManager(Region region)
Returns aTransferManagerfor the given region, or throws an exception when unable. The returnedTransferManagerwill always be instantiated from whateverAmazonS3is in the cache, whether provided withuseClient(AmazonS3)or instantiated automatically fromAWSCredentials. AnyTransferManagerreturned could be shut down if a new underlyingAmazonS3is provided withuseClient(AmazonS3).- Parameters:
region- The region the returnedTransferManagerwill be configured to use.- Returns:
- A transfer manager for the given region from the cache, or one
instantiated automatically from any existing
AmazonS3,
-
-