本文整理汇总了Java中com.amazonaws.AmazonWebServiceClient.setRegion方法的典型用法代码示例。如果您正苦于以下问题:Java AmazonWebServiceClient.setRegion方法的具体用法?Java AmazonWebServiceClient.setRegion怎么用?Java AmazonWebServiceClient.setRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.AmazonWebServiceClient
的用法示例。
在下文中一共展示了AmazonWebServiceClient.setRegion方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBuildWithRegion
import com.amazonaws.AmazonWebServiceClient; //导入方法依赖的package包/类
@Test
@SuppressWarnings("deprecation")
public void testBuildWithRegion() {
Region region = Region.getRegion(Regions.US_WEST_1);
AmazonWebServiceClient mockedS3 = createMock(AmazonWebServiceClient.class);
AwsClientBuilder builder = createPartialMock(AwsClientBuilder.class,
new String[] {"instantiateClient"}, region);
try {
expect(builder.instantiateClient(AmazonS3Client.class))
.andReturn(mockedS3);
mockedS3.setRegion(region);
expectLastCall();
replay(mockedS3, builder);
builder.build(AmazonS3Client.class);
verify(mockedS3, builder);
} catch (Exception ex) {
fail("Unexpected exception: " + ex.getMessage());
}
}
示例2: configureServiceClient
import com.amazonaws.AmazonWebServiceClient; //导入方法依赖的package包/类
static void configureServiceClient(AmazonWebServiceClient client, Optional<String> endpoint, Optional<String> regionName)
{
// Configure endpoint or region. Endpoint takes precedence over region.
if (endpoint.isPresent()) {
client.setEndpoint(endpoint.get());
}
else if (regionName.isPresent()) {
Regions region;
try {
region = Regions.fromName(regionName.get());
}
catch (IllegalArgumentException e) {
throw new ConfigException("Illegal AWS region: " + regionName.get());
}
client.setRegion(Region.getRegion(region));
}
}
示例3: createClient
import com.amazonaws.AmazonWebServiceClient; //导入方法依赖的package包/类
private C createClient() {
Class<? extends C> clientImplType = factory.getClientImplType();
C client = ReflectionUtils.newInstance(
clientImplType, credentials, configuration);
if (client instanceof AmazonWebServiceClient) {
AmazonWebServiceClient awsc = (AmazonWebServiceClient) client;
if (region != null) {
awsc.setRegion(region);
}
if (endpoint != null) {
awsc.setEndpoint(endpoint);
}
}
return client;
}