diff --git a/src/main/java/org/socialsignin/spring/data/dynamodb/repository/config/DynamoDBMapperFactory.java b/src/main/java/org/socialsignin/spring/data/dynamodb/repository/config/DynamoDBMapperFactory.java index 9d4528c9..8cb5e801 100644 --- a/src/main/java/org/socialsignin/spring/data/dynamodb/repository/config/DynamoDBMapperFactory.java +++ b/src/main/java/org/socialsignin/spring/data/dynamodb/repository/config/DynamoDBMapperFactory.java @@ -35,8 +35,7 @@ public DynamoDBMapperFactory() { } @Override - public synchronized DynamoDBMapper getObject() throws Exception { - // fix issue #230 + public DynamoDBMapper getObject() throws Exception { return new DynamoDBMapper(amazonDynamoDB, dynamoDBMapperConfig); } diff --git a/src/main/java/org/socialsignin/spring/data/dynamodb/repository/config/DynamoDBRepositoryConfigExtension.java b/src/main/java/org/socialsignin/spring/data/dynamodb/repository/config/DynamoDBRepositoryConfigExtension.java index af5fae4b..dd52c2da 100644 --- a/src/main/java/org/socialsignin/spring/data/dynamodb/repository/config/DynamoDBRepositoryConfigExtension.java +++ b/src/main/java/org/socialsignin/spring/data/dynamodb/repository/config/DynamoDBRepositoryConfigExtension.java @@ -17,6 +17,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -226,10 +227,14 @@ public void registerBeansForRoot(BeanDefinitionRegistry registry, // Store for later to be used by #postProcess, too this.registry = registry; - BeanDefinitionBuilder dynamoDBMapperConfigBuiilder = BeanDefinitionBuilder - .genericBeanDefinition(DynamoDBMapperConfigFactory.class); - registry.registerBeanDefinition(getBeanNameWithModulePrefix("DynamoDBMapperConfig"), - dynamoDBMapperConfigBuiilder.getBeanDefinition()); + // Fix issue #233 + Optional dynamoDBMapperConfigRef = configurationSource.getAttribute("dynamoDBMapperConfigRef"); + if (!dynamoDBMapperConfigRef.isPresent()) { + BeanDefinitionBuilder dynamoDBMapperConfigBuiilder = BeanDefinitionBuilder + .genericBeanDefinition(DynamoDBMapperConfigFactory.class); + registry.registerBeanDefinition(getBeanNameWithModulePrefix("DynamoDBMapperConfig"), + dynamoDBMapperConfigBuiilder.getBeanDefinition()); + } BeanDefinitionBuilder dynamoDBMapperBuilder = BeanDefinitionBuilder .genericBeanDefinition(DynamoDBMapperFactory.class);