Skip to content

Commit 1143090

Browse files
committed
Merge branch 'master' of github.com:derjust/spring-data-dynamodb
2 parents 47cf102 + acd0e9d commit 1143090

File tree

6 files changed

+122
-11
lines changed

6 files changed

+122
-11
lines changed

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ The major and minor number of this library refers to the compatible Spring frame
3131

3232
API changes will follow SEMVER and loosly the Spring Framework releases.
3333

34-
| `spring-data-dynamodb` version | Spring Framework compatibility | Spring Data compatibility |
35-
| ------------------------------- | ------------------------------ | ------------------------- |
36-
| 1.0.x | >= 3.1 && < 4.2 | |
37-
| 4.2.x | >= 4.2 && < 4.3 | Gosling-SR1 |
38-
| 4.3.x | >= 4.3 && < 5.0 | Gosling-SR1 |
39-
| 4.4.x | >= 4.3 && < 5.0 | Hopper-SR2 |
40-
| 4.5.x | >= 4.3 && < 5.0 | Ingalls |
41-
| 5.0.x | >= 5.0 | Kay-SR1 |
34+
| `spring-data-dynamodb` version | Spring Boot compatibility |Spring Framework compatibility | Spring Data compatibility |
35+
| ------------------------------- | ------------------------------ | ------------------------------ | ------------------------- |
36+
| 1.0.x | | >= 3.1 && < 4.2 | |
37+
| 4.2.x | => 1.3.0 && < 1.4.0 | >= 4.2 && < 4.3 | Gosling-SR1 |
38+
| 4.3.x | => 1.4.0 < 2.0 | >= 4.3 && < 5.0 | Gosling-SR1 |
39+
| 4.4.x | => 1.4.0 < 2.0 | >= 4.3 && < 5.0 | Hopper-SR2 |
40+
| 4.5.x | => 1.4.0 < 2.0 | >= 4.3 && < 5.0 | Ingalls |
41+
| 5.0.x | => 2.0 | >= 5.0 | Kay-SR1 |
4242

4343
`spring-data-dynamodb` depends directly on `spring-data` as also `spring-context`, `spring-data` and `spring-tx`.
4444

@@ -148,6 +148,11 @@ public class User {
148148

149149
public User() {
150150
}
151+
152+
public User(String firstName, String lastName) {
153+
this.firstName = firstName;
154+
this.lastName = lastName;
155+
}
151156

152157
@DynamoDBHashKey
153158
@DynamoDBAutoGeneratedKey
@@ -286,6 +291,7 @@ Advanced topics can be found in the [wiki](https://github.com/derjust/spring-dat
286291
## Release process ##
287292

288293
1. Check `pom.xml` for the proper `<version />` tag
294+
1. Check `pom.xml` SpecificaitonVersion entries
289295
1. Update `src/changes/changes.xml` timestamp of the release version
290296
1. Update `README.md` version for the Maven/Gradle examples
291297

pom.xml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
<properties>
4040
<spring.version>5.0.1.RELEASE</spring.version>
4141
<spring-data.version>Kay-SR1</spring-data.version>
42+
<artifact.selectedVersion.minorVersion>0</artifact.selectedVersion.minorVersion>
43+
4244
<hibernate-validator.version>5.2.4.Final</hibernate-validator.version>
4345
<aws-java-sdk.version>1.11.232</aws-java-sdk.version>
4446
<junit.version>4.12</junit.version>
@@ -151,7 +153,7 @@
151153
<groupId>javax.enterprise</groupId>
152154
<artifactId>cdi-api</artifactId>
153155
<version>${cdi.version}</version>
154-
<scope>provided</scope>
156+
<scope>compile</scope>
155157
</dependency>
156158

157159
<!-- TEST -->
@@ -225,9 +227,28 @@
225227
<artifactId>maven-surefire-plugin</artifactId>
226228
<version>2.20.1</version>
227229
</plugin>
230+
<plugin>
231+
<artifactId>maven-jar-plugin</artifactId>
232+
<version>3.0.2</version>
233+
</plugin>
228234
</plugins>
229235
</pluginManagement>
230236
<plugins>
237+
<plugin>
238+
<groupId>org.apache.maven.plugins</groupId>
239+
<artifactId>maven-jar-plugin</artifactId>
240+
<configuration>
241+
<archive>
242+
<manifest>
243+
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
244+
</manifest>
245+
<manifestEntries>
246+
<Specification-Title>Spring Data</Specification-Title>
247+
<Specification-Version>2.0</Specification-Version>
248+
</manifestEntries>
249+
</archive>
250+
</configuration>
251+
</plugin>
231252
<plugin>
232253
<artifactId>maven-compiler-plugin</artifactId>
233254
<configuration>
@@ -693,6 +714,10 @@
693714
<name>Alex Arana</name>
694715
<url>https://github.com/alexarana</url>
695716
</contributor>
717+
<contributor>
718+
<name>Davin</name>
719+
<url>https://github.com/Davinpidoto</url>
720+
</contributor>
696721
</contributors>
697722

698723

src/changes/changes.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
<action dev="derjust" type="add" date="2018-01-23">
3737
Allow for JUnit tests to use a in-memory DynamoDB instance
3838
</action>
39+
<action dev="Davinpidoto" issue="122" type="add" date="2018-01-27">
40+
Added documentation about Spring-Boot compatibility
41+
</action>
42+
<action dev="derjust" issue="122" type="add" date="2018-01-27">
43+
Added logging of AWS/Spring-Data/this version and potential compatibility issues
44+
</action>
3945
</release>
4046
<release version="5.0.1" date="2018-01-06" description="Maintenance release">
4147
<action dev="derjust" issue="68" type="fix" date="2017-12-01" >

src/main/java/org/socialsignin/spring/data/dynamodb/repository/cdi/DynamoDBRepositoryBean.java

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,23 @@
1717

1818
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
1919
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig;
20+
import com.amazonaws.util.VersionInfoUtils;
21+
22+
import org.slf4j.Logger;
23+
import org.slf4j.LoggerFactory;
2024
import org.socialsignin.spring.data.dynamodb.core.DynamoDBOperations;
2125
import org.socialsignin.spring.data.dynamodb.core.DynamoDBTemplate;
2226
import org.socialsignin.spring.data.dynamodb.repository.support.DynamoDBRepositoryFactory;
2327
import org.springframework.data.repository.cdi.CdiRepositoryBean;
2428
import org.springframework.util.Assert;
29+
import org.springframework.data.util.Version;
2530

2631
import javax.enterprise.context.spi.CreationalContext;
2732
import javax.enterprise.inject.spi.Bean;
2833
import javax.enterprise.inject.spi.BeanManager;
2934
import java.lang.annotation.Annotation;
3035
import java.util.Set;
36+
import java.util.StringTokenizer;
3137

3238
/**
3339
* A bean which represents a DynamoDB repository.
@@ -37,6 +43,48 @@
3743
* The type of the repository.
3844
*/
3945
class DynamoDBRepositoryBean<T> extends CdiRepositoryBean<T> {
46+
private static final Logger LOGGER = LoggerFactory.getLogger(DynamoDBRepositoryBean.class);
47+
48+
static {
49+
String awsSdkVersion = VersionInfoUtils.getVersion();
50+
String springDataVersion = Version.class.getPackage().getImplementationVersion();
51+
52+
String thisSpecVersion = DynamoDBRepositoryBean.class.getPackage().getSpecificationVersion();
53+
String thisImplVersion = DynamoDBRepositoryBean.class.getPackage().getImplementationVersion();
54+
55+
LOGGER.info("Spring Data DynamoDB Version: {} ({})", thisImplVersion, thisSpecVersion);
56+
LOGGER.info("Spring Data Version: {}", springDataVersion);
57+
LOGGER.info("AWS SDK Version: {}", awsSdkVersion);
58+
LOGGER.info("Java Version: {} - {} {}", System.getProperty("java.version"),
59+
System.getProperty("java.vm.name"), System.getProperty("java.vm.version"));
60+
LOGGER.info("Platform Details: {} {}", System.getProperty("os.name"),
61+
System.getProperty("os.version"));
62+
63+
if (!isCompatible(springDataVersion, thisSpecVersion)) {
64+
LOGGER.warn("This Spring Data DynamoDB implementation might not be compatible with the available Spring Data classes on the classpath!"
65+
+ System.getProperty("line.separator") + "NoDefClassFoundExceptions or similar might occur!");
66+
}
67+
}
68+
69+
protected static boolean isCompatible(String spec, String impl) {
70+
if (spec == null && impl == null) {
71+
return false;
72+
} else if (spec == null) {
73+
spec = "";
74+
} else if (impl == null) {
75+
impl = "";
76+
}
77+
StringTokenizer specTokenizer = new StringTokenizer(spec, ".");
78+
StringTokenizer implTokenizer = new StringTokenizer(impl, ".");
79+
80+
String specMajor = specTokenizer.hasMoreTokens() ? specTokenizer.nextToken() : "0";
81+
String specMinor = specTokenizer.hasMoreTokens() ? specTokenizer.nextToken() : "0";
82+
83+
String implMajor = implTokenizer.hasMoreTokens() ? implTokenizer.nextToken() : "0";
84+
String implMinor = implTokenizer.hasMoreTokens() ? implTokenizer.nextToken() : "0";
85+
86+
return specMajor.equals(implMajor) && specMinor.equals(implMinor);
87+
}
4088

4189
private final Bean<AmazonDynamoDB> amazonDynamoDBBean;
4290

@@ -49,7 +97,9 @@ class DynamoDBRepositoryBean<T> extends CdiRepositoryBean<T> {
4997
*
5098
* @param beanManager
5199
* must not be {@literal null}.
52-
* @param dynamoDBMapperBean
100+
* @param amazonDynamoDBBean
101+
* must not be {@literal null}.
102+
* @param dynamoDBOperationsBean
53103
* must not be {@literal null}.
54104
* @param qualifiers
55105
* must not be {@literal null}.

src/main/java/org/socialsignin/spring/data/dynamodb/repository/config/DynamoDBRepositoryConfigExtension.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class DynamoDBRepositoryConfigExtension extends RepositoryConfigurationEx
3737

3838
private static final String DYNAMO_DB_OPERATIONS_REF = "dynamodb-operations-ref";
3939

40-
4140
private static final String AMAZON_DYNAMODB_REF = "amazon-dynamodb-ref";
4241

4342
@Override

src/test/java/org/socialsignin/spring/data/dynamodb/repository/cdi/DynamoDBRepositoryBeanTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperConfig;
2020
import org.junit.Rule;
2121
import org.junit.Test;
22+
import org.junit.experimental.theories.suppliers.TestedOn;
2223
import org.junit.rules.ExpectedException;
2324
import org.junit.runner.RunWith;
2425
import org.mockito.Mock;
@@ -31,7 +32,9 @@
3132
import java.util.Collections;
3233
import java.util.Set;
3334

35+
import static org.junit.Assert.assertFalse;
3436
import static org.junit.Assert.assertNotNull;
37+
import static org.junit.Assert.assertTrue;
3538

3639
@RunWith(MockitoJUnitRunner.class)
3740
public class DynamoDBRepositoryBeanTest {
@@ -93,4 +96,26 @@ public void testSetOperationFail2() {
9396
DynamoDBRepositoryBean underTest = new DynamoDBRepositoryBean(beanManager, amazonDynamoDBBean,
9497
null, dynamoDBOperationsBean, qualifiers, repositoryType);
9598
}
99+
100+
@Test
101+
public void testVersionNullNull() {
102+
assertFalse(DynamoDBRepositoryBean.isCompatible(null, null));
103+
}
104+
105+
@Test
106+
public void testVersionNullValue() {
107+
assertFalse(DynamoDBRepositoryBean.isCompatible(null, "1.0."));
108+
assertFalse(DynamoDBRepositoryBean.isCompatible("1.0", null));
109+
}
110+
111+
@Test
112+
public void testVersionCompatible() {
113+
assertTrue(DynamoDBRepositoryBean.isCompatible("1.0", "1.0"));
114+
assertTrue(DynamoDBRepositoryBean.isCompatible("1.0.0.0.1", "1.0..0.0.1"));
115+
116+
assertFalse(DynamoDBRepositoryBean.isCompatible("1.1", "1.0"));
117+
assertFalse(DynamoDBRepositoryBean.isCompatible("1.0", "2.0"));
118+
119+
assertTrue(DynamoDBRepositoryBean.isCompatible("1.0.0-SR", "1.0.0-SR"));
120+
}
96121
}

0 commit comments

Comments
 (0)