Class S3ClientCache
- java.lang.Object
-
- com.amazonaws.services.dynamodbv2.datamodeling.S3ClientCache
-
public class S3ClientCache extends Object
A smart Map forAmazonS3
objects.S3ClientCache
keeps the clients organized by region, and if providedAWSCredentials
will 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 AmazonS3
getClient(Region s3region)
Returns a client for the requested region, or throws an exception when unable.TransferManager
getTransferManager(Region region)
Returns aTransferManager
for the given region, or throws an exception when unable.void
useClient(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 differentS3ClientOptions
or use aAmazonS3EncryptionClient
in place of a regular client. Using a new client will also forcibly shut down anyTransferManager
that has been instantiated with that client, with theTransferManager.shutdownNow()
method.- Parameters:
client
- AnAmazonS3
to 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 returnedAmazonS3
will be configured to use.- Returns:
- A client for the given region from the cache, either instantiated
automatically from the provided
AWSCredentials
or provided withuseClient(AmazonS3)
. - Throws:
IllegalArgumentException
- When a region is requested that has not been provided to the cache withuseClient(AmazonS3)
, and the cache has noAWSCredentials
with which a client may be instantiated.
-
getTransferManager
public TransferManager getTransferManager(Region region)
Returns aTransferManager
for the given region, or throws an exception when unable. The returnedTransferManager
will always be instantiated from whateverAmazonS3
is in the cache, whether provided withuseClient(AmazonS3)
or instantiated automatically fromAWSCredentials
. AnyTransferManager
returned could be shut down if a new underlyingAmazonS3
is provided withuseClient(AmazonS3)
.- Parameters:
region
- The region the returnedTransferManager
will be configured to use.- Returns:
- A transfer manager for the given region from the cache, or one
instantiated automatically from any existing
AmazonS3
,
-
-