Skip to content

Commit 54f7146

Browse files
committed
#539 - Polishing.
Add author tags. Simplify dependency setup. Replace logger declarations with Lombok's CommonsLog. Simplify test annotations. Disable WAN module as the WAN server does not stop after running tests. Reformat code.
1 parent fa0021c commit 54f7146

File tree

121 files changed

+1145
-1077
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+1145
-1077
lines changed

README.md

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ This repository contains example projects for the different Spring Data modules
66

77
We have separate folders for the samples of individual modules:
88

9+
## Spring Data for Apache Cassandra
10+
11+
* `example` - Shows core Spring Data support for Apache Cassandra.
12+
* `java8` - Java 8 specific functionality like the support for JSR-310 types in object mapping.
13+
* `kotlin` - Example for using Cassandra with Kotlin.
14+
* `reactive` - Example project to show reactive template and repository support.
15+
16+
## Spring Data Elasticsearch
17+
18+
* `example` - Example how to use basic text search, geo-spatial search and facets.
19+
* `rest` - Example how to use the High Level REST Client backing template and repository.
20+
* `reactive` - Example how to use reactive client, template and repository features.
21+
922
## Spring Data for Apache Geode
1023

1124
* `events` - In this example the test will make use of event handlers and async event queue to handle events.
@@ -17,6 +30,10 @@ We have separate folders for the samples of individual modules:
1730
* `transactions` - In this example the client will perform operations within a transaction. First, it will do a successful transaction where entries are saved to the server, and then a failed transaction where all changes are reverted.
1831
* `wan` - In these example two servers are deployed. One server populates itself with data, and the other server gets populated with that data via WAN replication.
1932

33+
## Spring Data JDBC
34+
35+
* `basic` - Basic usage of Spring Data JDBC.
36+
2037
## Spring Data JPA
2138

2239
* `eclipselink` - Sample project to show how to use Spring Data JPA with Spring Boot and [Eclipselink](https://www.eclipse.org/eclipselink/).
@@ -30,6 +47,10 @@ We have separate folders for the samples of individual modules:
3047
* `showcase` - Refactoring show case of how to improve a plain-JPA-based persistence layer by using Spring Data JPA (read: removing close to all of the implementation code). Follow the `demo.txt` file for detailed instructions.
3148
* `vavr` - Shows the support of [Vavr](https://www.vavr.io) collection types as return types for query methods.
3249

50+
## Spring Data LDAP
51+
52+
* `example` - Sample for Spring Data repositories to access an LDAP store.
53+
3354
## Spring Data MongoDB
3455

3556
* `aggregation` - Example project to showcase the MongoDB aggregation framework support.
@@ -46,14 +67,13 @@ We have separate folders for the samples of individual modules:
4667
* `text-search` - Example project showing usage of MongoDB text search feature.
4768
* `transactions` - Example project for imperative and reactive MongoDB 4.0 transaction support.
4869

49-
## Spring Data REST
70+
## Spring Data Neo4j
5071

51-
* `headers` - A sample showing the population of HTTP headers and the usage of them to perform conditional `GET` requests.
52-
* `multi-store` - A sample REST web-service based on both Spring Data JPA and Spring Data MongoDB.
53-
* `projections` - A sample REST web-service showing how to use projections.
54-
* `security` - A sample REST web-service secured using Spring Security.
55-
* `starbucks` - A sample REST web-service built with Spring Data REST and MongoDB.
56-
* `uri-customizations` - Example project to show URI customization capabilities.
72+
* `example` - Example to show basic node and relationship entities and repository usage.
73+
74+
## Spring Data R2DBC
75+
76+
* `example` - Basic usage of Spring Data R2DBC.
5777

5878
## Spring Data Redis
5979

@@ -64,46 +84,26 @@ We have separate folders for the samples of individual modules:
6484
* `sentinel` - Example for Redis Sentinel support.
6585
* `streams` - Example for [Redis Streams](https://redis.io/topics/streams-intro) support.
6686

87+
## Spring Data REST
88+
89+
* `headers` - A sample showing the population of HTTP headers and the usage of them to perform conditional `GET` requests.
90+
* `multi-store` - A sample REST web-service based on both Spring Data JPA and Spring Data MongoDB.
91+
* `projections` - A sample REST web-service showing how to use projections.
92+
* `security` - A sample REST web-service secured using Spring Security.
93+
* `starbucks` - A sample REST web-service built with Spring Data REST and MongoDB.
94+
* `uri-customizations` - Example project to show URI customization capabilities.
95+
6796
## Spring Data for Apache Solr
6897

6998
* `example` - Example project for Spring Data repositories for Apache Solr.
7099
* `managed-schema` - Example project to show managed schema integration.
71100

72-
## Spring Data Elasticsearch
73-
74-
* `example` - Example how to use basic text search, geo-spatial search and facets.
75-
* `rest` - Example how to use the High Level REST Client backing template and repository.
76-
* `reactive` - Example how to use reactive client, template and repository features.
77-
78-
## Spring Data Neo4j
79-
80-
* `example` - Example to show basic node and relationship entities and repository usage.
81-
82101
## Spring Data web support
83102

84103
* `projections` - Example for Spring Data web support for JSONPath and XPath expressions on projection interfaces.
85104
* `querydsl` - Example for Spring Data Querydsl web integration (creating a `Predicate` from web requests).
86105
* `web` - Example for Spring Data web integration (binding `Pageable` instances to Spring MVC controller methods, using interfaces to bind Spring MVC request payloads).
87106

88-
## Spring Data for Apache Cassandra
89-
90-
* `example` - Shows core Spring Data support for Apache Cassandra.
91-
* `java8` - Java 8 specific functionality like the support for JSR-310 types in object mapping.
92-
* `kotlin` - Example for using Cassandra with Kotlin.
93-
* `reactive` - Example project to show reactive template and repository support.
94-
95-
## Spring Data LDAP
96-
97-
* `example` - Sample for Spring Data repositories to access an LDAP store.
98-
99-
## Spring Data JDBC
100-
101-
* `basic` - Basic usage of Spring Data JDBC.
102-
103-
## Spring Data R2DBC
104-
105-
* `example` - Basic usage of Spring Data R2DBC.
106-
107107
## Miscellaneous
108108

109109
* `bom` - Example project how to use the Spring Data release train bom in non-Spring-Boot scenarios.

geode/events/pom.xml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@
22
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xmlns="http://maven.apache.org/POM/4.0.0"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5-
<parent>
6-
<groupId>example.springdata.geode</groupId>
7-
<artifactId>spring-data-geode-examples</artifactId>
8-
<version>1.0-SNAPSHOT</version>
9-
</parent>
10-
<modelVersion>4.0.0</modelVersion>
11-
<artifactId>events</artifactId>
5+
<modelVersion>4.0.0</modelVersion>
126

13-
<dependencies>
7+
<parent>
8+
<groupId>org.springframework.data.examples</groupId>
9+
<artifactId>spring-data-geode-examples</artifactId>
10+
<version>2.0.0.BUILD-SNAPSHOT</version>
11+
</parent>
1412

15-
</dependencies>
13+
<artifactId>events</artifactId>
1614

17-
</project>
15+
</project>

geode/events/src/main/java/example/springdata/geode/server/events/Address.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package example.springdata.geode.server.events;
1817

1918
import lombok.Data;
@@ -29,6 +28,7 @@
2928
*/
3029
@Data
3130
public class Address implements Serializable {
31+
3232
private String street;
3333
private String city;
3434
private String country;

geode/events/src/main/java/example/springdata/geode/server/events/Customer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package example.springdata.geode.server.events;
1817

1918
import lombok.Data;
@@ -48,4 +47,4 @@ public Customer(Long id, EmailAddress emailAddress, String firstName, String las
4847
this.lastName = lastName;
4948
this.addresses = Arrays.asList(addresses);
5049
}
51-
}
50+
}

geode/events/src/main/java/example/springdata/geode/server/events/CustomerCacheWriter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package example.springdata.geode.server.events;
1817

1918
import org.apache.geode.cache.CacheWriterException;
@@ -22,6 +21,9 @@
2221
import org.apache.geode.internal.cache.EntryEventImpl;
2322
import org.springframework.stereotype.Component;
2423

24+
/**
25+
* @author Patrick Johnson
26+
*/
2527
@Component
2628
public class CustomerCacheWriter extends CacheWriterAdapter<Long, Customer> {
2729

geode/events/src/main/java/example/springdata/geode/server/events/CustomerRepository.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package example.springdata.geode.server.events;
1817

1918
import org.springframework.data.repository.CrudRepository;
2019

20+
/**
21+
* @author Patrick Johnson
22+
*/
2123
public interface CustomerRepository extends CrudRepository<Customer, Long> {
2224
}

geode/events/src/main/java/example/springdata/geode/server/events/EmailAddress.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package example.springdata.geode.server.events;
1817

1918
import lombok.Data;
@@ -28,10 +27,11 @@
2827
*/
2928
@Data
3029
public class EmailAddress implements Serializable {
30+
3131
private String value;
3232

3333
public EmailAddress(String value) {
3434

3535
this.value = value;
3636
}
37-
}
37+
}

geode/events/src/main/java/example/springdata/geode/server/events/EventServer.java

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,84 +13,79 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package example.springdata.geode.server.events;
1817

18+
import java.math.BigDecimal;
19+
import java.util.List;
20+
import java.util.Random;
21+
import java.util.stream.IntStream;
22+
import java.util.stream.LongStream;
23+
24+
import lombok.extern.apachecommons.CommonsLog;
1925
import org.apache.geode.cache.Region;
2026
import org.slf4j.Logger;
2127
import org.slf4j.LoggerFactory;
28+
2229
import org.springframework.beans.factory.annotation.Qualifier;
2330
import org.springframework.boot.ApplicationRunner;
2431
import org.springframework.boot.WebApplicationType;
2532
import org.springframework.boot.autoconfigure.SpringBootApplication;
2633
import org.springframework.boot.builder.SpringApplicationBuilder;
2734
import org.springframework.context.annotation.Bean;
2835

29-
import java.math.BigDecimal;
30-
import java.util.List;
31-
import java.util.Random;
32-
import java.util.stream.IntStream;
33-
import java.util.stream.LongStream;
34-
35-
@SpringBootApplication(scanBasePackageClasses = EventServerConfig.class)
36+
/**
37+
* @author Patrick Johnson
38+
*/
39+
@SpringBootApplication
40+
@CommonsLog
3641
public class EventServer {
3742

38-
private Logger logger = LoggerFactory.getLogger(this.getClass());
39-
4043
public static void main(String[] args) {
41-
new SpringApplicationBuilder(EventServer.class)
42-
.web(WebApplicationType.NONE)
43-
.build()
44-
.run(args);
44+
new SpringApplicationBuilder(EventServer.class).web(WebApplicationType.NONE).build().run(args);
4545
}
4646

4747
@Bean
4848
public ApplicationRunner runner(CustomerRepository customerRepository, OrderRepository orderRepository,
49-
ProductRepository productRepository, OrderProductSummaryRepository orderProductSummaryRepository, @Qualifier("Products") Region<Long, Product> products) {
49+
ProductRepository productRepository, OrderProductSummaryRepository orderProductSummaryRepository,
50+
@Qualifier("Products") Region<Long, Product> products) {
5051
return args -> {
5152
createCustomerData(customerRepository);
5253

5354
createProducts(productRepository);
5455

5556
createOrders(productRepository, orderRepository);
5657

57-
logger.info("Completed creating orders ");
58+
log.info("Completed creating orders ");
5859

59-
final List<OrderProductSummary> allForProductID = orderProductSummaryRepository.findAllForProductID(3L);
60-
allForProductID.forEach(orderProductSummary -> logger.info("orderProductSummary = " + orderProductSummary));
60+
List<OrderProductSummary> allForProductID = orderProductSummaryRepository.findAllForProductID(3L);
61+
allForProductID.forEach(orderProductSummary -> log.info("orderProductSummary = " + orderProductSummary));
6162
};
6263
}
6364

6465
private void createOrders(ProductRepository productRepository, OrderRepository orderRepository) {
6566
Random random = new Random(System.nanoTime());
6667
Address address = new Address("it", "doesn't", "matter");
67-
LongStream.rangeClosed(1, 10).forEach((orderId) ->
68-
LongStream.rangeClosed(1, 300).forEach((customerId) -> {
69-
Order order = new Order(orderId, customerId, address);
70-
IntStream.rangeClosed(0, random.nextInt(3) + 1).forEach((lineItemCount) -> {
71-
int quantity = random.nextInt(3) + 1;
72-
long productId = random.nextInt(3) + 1;
73-
order.add(new LineItem(productRepository.findById(productId).get(), quantity));
74-
});
75-
orderRepository.save(order);
76-
}));
68+
LongStream.rangeClosed(1, 10).forEach((orderId) -> LongStream.rangeClosed(1, 300).forEach((customerId) -> {
69+
Order order = new Order(orderId, customerId, address);
70+
IntStream.rangeClosed(0, random.nextInt(3) + 1).forEach((lineItemCount) -> {
71+
int quantity = random.nextInt(3) + 1;
72+
long productId = random.nextInt(3) + 1;
73+
order.add(new LineItem(productRepository.findById(productId).get(), quantity));
74+
});
75+
orderRepository.save(order);
76+
}));
7777
}
7878

7979
private void createProducts(ProductRepository productRepository) {
80-
productRepository.save(new Product(1L, "Apple iPod", new BigDecimal("99.99"),
81-
"An Apple portable music player"));
82-
productRepository.save(new Product(2L, "Apple iPad", new BigDecimal("499.99"),
83-
"An Apple tablet device"));
84-
Product macbook = new Product(3L, "Apple macBook", new BigDecimal("899.99"),
85-
"An Apple notebook computer");
80+
productRepository.save(new Product(1L, "Apple iPod", new BigDecimal("99.99"), "An Apple portable music player"));
81+
productRepository.save(new Product(2L, "Apple iPad", new BigDecimal("499.99"), "An Apple tablet device"));
82+
Product macbook = new Product(3L, "Apple macBook", new BigDecimal("899.99"), "An Apple notebook computer");
8683
macbook.addAttribute("warranty", "included");
8784
productRepository.save(macbook);
8885
}
8986

9087
private void createCustomerData(CustomerRepository customerRepository) {
91-
LongStream.rangeClosed(0, 300)
92-
.parallel()
93-
.forEach(customerId ->
94-
customerRepository.save(new Customer(customerId, new EmailAddress(customerId + "@2.com"), "John" + customerId, "Smith" + customerId)));
88+
LongStream.rangeClosed(0, 300).parallel().forEach(customerId -> customerRepository.save(
89+
new Customer(customerId, new EmailAddress(customerId + "@2.com"), "John" + customerId, "Smith" + customerId)));
9590
}
96-
}
91+
}

0 commit comments

Comments
 (0)