本文整理汇总了Java中com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig类的典型用法代码示例。如果您正苦于以下问题:Java DynamoDBMapperConfig类的具体用法?Java DynamoDBMapperConfig怎么用?Java DynamoDBMapperConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DynamoDBMapperConfig类属于com.amazonaws.services.dynamodbv2.datamodeling包,在下文中一共展示了DynamoDBMapperConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
@PostConstruct
protected void init() {
configureAWSLogAgent();
credentialsProvider = new InstanceProfileCredentialsProvider();
region = Regions.getCurrentRegion();
amazonDynamoDB.setRegion(region);
dbPrefix = AmazonConfigProvider.getDynamoDbPrefix();
DynamoDBMapperConfig config = new DynamoDBMapperConfig.Builder().withTableNameOverride(DynamoDBMapperConfig.TableNameOverride.
withTableNamePrefix(dbPrefix)).build();
mapper = new DynamoDBMapper(amazonDynamoDB, config);
tablesWithPrefix = Arrays.stream(tables).map(s -> dbPrefix.concat(s)).collect(Collectors.toList());
if (customBucketName != null) {
customBucketName = customBucketName.toLowerCase();
}
if ((customBucketName.isEmpty() || CUSTOM_BUCKET_NAME_DEFAULT_VALUE.equals(customBucketName)) && !validateBucketName(customBucketName).isValid()) {
customBucketName = null;
}
}
示例2: testCreateQueryRequestFromExpression
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
private static <T> QueryRequest testCreateQueryRequestFromExpression(
Class<T> clazz, DynamoDBQueryExpression<T> queryExpression,
String expectedErrorMessage) {
try {
QueryRequest request = (QueryRequest) testedMethod.invoke(mapper, clazz, queryExpression, DynamoDBMapperConfig.DEFAULT);
if (expectedErrorMessage != null) {
fail("Exception containing messsage ("
+ expectedErrorMessage + ") is expected.");
}
return request;
} catch (InvocationTargetException ite) {
if (expectedErrorMessage != null) {
assertTrue("Exception message [" + ite.getCause().getMessage() + "] does not contain " +
"the expected message [" + expectedErrorMessage + "].",
ite.getCause().getMessage().contains(expectedErrorMessage));
} else {
ite.getCause().printStackTrace();
fail("Internal error when calling createQueryRequestFromExpressio method");
}
} catch (Exception e) {
fail(e.getMessage());
}
return null;
}
示例3: DynamoDBRepositoryBean
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
/**
* Constructs a {@link DynamoDBRepositoryBean}.
*
* @param beanManager
* must not be {@literal null}.
* @param dynamoDBMapperBean
* must not be {@literal null}.
* @param qualifiers
* must not be {@literal null}.
* @param repositoryType
* must not be {@literal null}.
*/
DynamoDBRepositoryBean(BeanManager beanManager, Bean<AmazonDynamoDB> amazonDynamoDBBean,
Bean<DynamoDBMapperConfig> dynamoDBMapperConfigBean,Bean<DynamoDBOperations> dynamoDBOperationsBean, Set<Annotation> qualifiers, Class<T> repositoryType) {
super(qualifiers, repositoryType, beanManager);
if (dynamoDBOperationsBean == null)
{
Assert.notNull(amazonDynamoDBBean);
}
else
{
Assert.isNull(amazonDynamoDBBean,"Cannot specify both amazonDynamoDB bean and dynamoDBOperationsBean in repository configuration");
Assert.isNull(dynamoDBMapperConfigBean,"Cannot specify both dynamoDBMapperConfigBean bean and dynamoDBOperationsBean in repository configuration");
}
this.amazonDynamoDBBean = amazonDynamoDBBean;
this.dynamoDBMapperConfigBean = dynamoDBMapperConfigBean;
this.dynamoDBOperationsBean = dynamoDBOperationsBean;
}
示例4: create
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
@Override
public T create(CreationalContext<T> creationalContext, Class<T> repositoryType) {
// Get an instance from the associated AmazonDynamoDB bean.
AmazonDynamoDB amazonDynamoDB = getDependencyInstance(amazonDynamoDBBean, AmazonDynamoDB.class);
// Get an instance from the associated optional AmazonDynamoDB bean.
DynamoDBMapperConfig dynamoDBMapperConfig = dynamoDBMapperConfigBean == null ? null : getDependencyInstance(
dynamoDBMapperConfigBean, DynamoDBMapperConfig.class);
DynamoDBOperations dynamoDBOperations = dynamoDBOperationsBean == null ? null
: getDependencyInstance(
dynamoDBOperationsBean, DynamoDBOperations.class);
if (dynamoDBOperations == null)
{
dynamoDBOperations = new DynamoDBTemplate(amazonDynamoDB,dynamoDBMapperConfig);
}
DynamoDBRepositoryFactory factory = new DynamoDBRepositoryFactory(dynamoDBOperations);
return factory.getRepository(repositoryType);
}
示例5: createRepositoryBean
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
/**
* Creates a {@link Bean}.
*
* @param <T>
* The type of the repository.
* @param repositoryType
* The class representing the repository.
* @param beanManager
* The BeanManager instance.
* @return The bean.
*/
private <T> Bean<T> createRepositoryBean(Class<T> repositoryType, Set<Annotation> qualifiers, BeanManager beanManager) {
// Determine the amazondbclient bean which matches the qualifiers of the
// repository.
Bean<AmazonDynamoDB> amazonDynamoDBBean = amazonDynamoDBs.get(qualifiers);
// Determine the dynamo db mapper configbean which matches the
// qualifiers of the repository.
Bean<DynamoDBMapperConfig> dynamoDBMapperConfigBean = dbMapperConfigs.get(qualifiers);
if (amazonDynamoDBBean == null) {
throw new UnsatisfiedResolutionException(String.format("Unable to resolve a bean for '%s' with qualifiers %s.",
AmazonDynamoDBClient.class.getName(), qualifiers));
}
Bean<DynamoDBOperations> dynamoDBOperationsBean = dynamoDBOperationss.get(qualifiers);
// Construct and return the repository bean.
return new DynamoDBRepositoryBean<T>(beanManager, amazonDynamoDBBean, dynamoDBMapperConfigBean,dynamoDBOperationsBean,qualifiers,
repositoryType);
}
示例6: DynamoDBMapperFactory
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
@Inject
public DynamoDBMapperFactory(AmazonDynamoDB client, Env env) {
mapper = new DynamoDBMapper(client,
new DynamoDBMapperConfig.Builder()
.withTableNameOverride(TableNameOverride
.withTableNamePrefix(env.get("DYNAMODB_TABLE_PREFIX").orElse("localhost") + "."))
.build());
}
示例7: dynamoDBMapperConfig
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
@Bean
public DynamoDBMapperConfig dynamoDBMapperConfig() {
DynamoDBMapperConfig.Builder builder = new DynamoDBMapperConfig.Builder();
builder.withTableNameOverride(DynamoDBMapperConfig.TableNameOverride.
withTableNamePrefix(getDynamoDbPrefix()));
return builder.build();
}
示例8: findAll
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
/**
* Find all rows in table given the entity object
*
* @return a list of entities found
* @throws DataAccessException
*/
public List<T> findAll() throws DataAccessException {
DynamoDBScanExpression dynamoDBScanExpression = new DynamoDBScanExpression();
DynamoDBMapperConfig config = new DynamoDBMapperConfig(DynamoDBMapperConfig.PaginationLoadingStrategy.EAGER_LOADING);
PaginatedScanList<T> paginatedScanList = dynamoDBMapper.scan(getType(), dynamoDBScanExpression, config);
paginatedScanList.loadAllResults();
List<T> list = new ArrayList<T>(paginatedScanList.size());
Iterator<T> iterator = paginatedScanList.iterator();
while (iterator.hasNext()) {
T element = iterator.next();
list.add(element);
}
return list;
}
示例9: setUp
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
client = ClientFactory.getInstance();
mapper = new DynamoDBMapper(client, new DynamoDBMapperConfig(
DynamoDBMapperConfig.SaveBehavior.CLOBBER,
DynamoDBMapperConfig.ConsistentReads.CONSISTENT, null));
fillTable();
}
示例10: setUp
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
@BeforeClass
public static void setUp() throws SecurityException, NoSuchMethodException {
AmazonDynamoDB dynamo = new AmazonDynamoDBClient();
mapper = TestDynamoDBMapperFactory.createDynamoDBMapper(dynamo);
testedMethod = DynamoDBMapper.class.getDeclaredMethod("createQueryRequestFromExpression", Class.class, DynamoDBQueryExpression.class, DynamoDBMapperConfig.class);
testedMethod.setAccessible(true);
}
示例11: getInstance
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
public static <T> AttributeTransformer.Parameters<T> getInstance(Class<T> clazz,
Map<String, AttributeValue> attribs, DynamoDBMapperConfig config, String tableName,
String hashKeyName, String rangeKeyName) {
// We use this relatively insane proxy setup so that modifications to the Parameters
// interface doesn't break our tests (unless it actually impacts our code).
FakeParameters<T> fakeParams = new FakeParameters<T>(clazz, attribs, config, tableName,
hashKeyName, rangeKeyName);
@SuppressWarnings("unchecked")
AttributeTransformer.Parameters<T> proxyObject = (AttributeTransformer.Parameters<T>) Proxy
.newProxyInstance(AttributeTransformer.class.getClassLoader(),
new Class[] { AttributeTransformer.Parameters.class },
new ParametersInvocationHandler<T>(fakeParams));
return proxyObject;
}
示例12: FakeParameters
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
private FakeParameters(Class<T> clazz, Map<String, AttributeValue> attribs,
DynamoDBMapperConfig config, String tableName, String hashKeyName, String rangeKeyName) {
super();
this.clazz = clazz;
this.attrs = Collections.unmodifiableMap(attribs);
this.config = config;
this.tableName = tableName;
this.hashKeyName = hashKeyName;
this.rangeKeyName = rangeKeyName;
}
示例13: testBatchWrite
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
private static void testBatchWrite(DynamoDBMapper mapper) {
// Create Forum item to save
Forum forumItem = new Forum();
forumItem.name = "Test BatchWrite Forum";
forumItem.threads = 0;
forumItem.category = "Amazon Web Services";
// Create Thread item to save
Thread threadItem = new Thread();
threadItem.forumName = "AmazonDynamoDB";
threadItem.subject = "My sample question";
threadItem.message = "BatchWrite message";
List<String> tags = new ArrayList<String>();
tags.add("batch operations");
tags.add("write");
threadItem.tags = new HashSet<String>(tags);
// Load ProductCatalog item to delete
Book book3 = mapper.load(Book.class, 903);
List<Object> objectsToWrite = Arrays.asList(forumItem, threadItem);
List<Book> objectsToDelete = Arrays.asList(book3);
DynamoDBMapperConfig config = new DynamoDBMapperConfig(DynamoDBMapperConfig.SaveBehavior.CLOBBER);
mapper.batchWrite(objectsToWrite, objectsToDelete, config);
}
示例14: testCRUDOperations
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
private static void testCRUDOperations() {
CatalogItem item = new CatalogItem();
item.setId(601);
item.setTitle("Book 601");
item.setISBN("611-1111111111");
item.setBookAuthors(new HashSet<String>(Arrays.asList("Author1", "Author2")));
// Save the item (book).
DynamoDBMapper mapper = new DynamoDBMapper(client);
mapper.save(item);
// Retrieve the item.
CatalogItem itemRetrieved = mapper.load(CatalogItem.class, 601);
System.out.println("Item retrieved:");
System.out.println(itemRetrieved);
// Update the item.
itemRetrieved.setISBN("622-2222222222");
itemRetrieved.setBookAuthors(new HashSet<String>(Arrays.asList("Author1", "Author3")));
mapper.save(itemRetrieved);
System.out.println("Item updated:");
System.out.println(itemRetrieved);
// Retrieve the updated item.
DynamoDBMapperConfig config = new DynamoDBMapperConfig(DynamoDBMapperConfig.ConsistentReads.CONSISTENT);
CatalogItem updatedItem = mapper.load(CatalogItem.class, 601, config);
System.out.println("Retrieved the previously updated item:");
System.out.println(updatedItem);
// Delete the item.
mapper.delete(updatedItem);
// Try to retrieve deleted item.
CatalogItem deletedItem = mapper.load(CatalogItem.class, updatedItem.getId(), config);
if (deletedItem == null) {
System.out.println("Done - Sample item is deleted.");
}
}
示例15: setDynamoDBMapperConfig
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig; //导入依赖的package包/类
public void setDynamoDBMapperConfig(DynamoDBMapperConfig dynamoDBMapperConfig)
{
this.dynamoDBMapperConfig = dynamoDBMapperConfig;
dynamoDBMapper = dynamoDBMapperConfig == null ? new DynamoDBMapper(amazonDynamoDB) : new DynamoDBMapper(
amazonDynamoDB, dynamoDBMapperConfig);
if (dynamoDBMapperConfig == null)
{
this.dynamoDBMapperConfig = DynamoDBMapperConfig.DEFAULT;
}
}