diff --git a/README.md b/README.md
index f9854851..c810429f 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,19 @@ This repository contains example projects for the different Spring Data modules
We have separate folders for the samples of individual modules:
+## Spring Data for Apache Cassandra
+
+* `example` - Shows core Spring Data support for Apache Cassandra.
+* `java8` - Java 8 specific functionality like the support for JSR-310 types in object mapping.
+* `kotlin` - Example for using Cassandra with Kotlin.
+* `reactive` - Example project to show reactive template and repository support.
+
+## Spring Data Elasticsearch
+
+* `example` - Example how to use basic text search, geo-spatial search and facets.
+* `rest` - Example how to use the High Level REST Client backing template and repository.
+* `reactive` - Example how to use reactive client, template and repository features.
+
## Spring Data for Apache Geode
* `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:
* `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.
* `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.
+## Spring Data JDBC
+
+* `basic` - Basic usage of Spring Data JDBC.
+
## Spring Data JPA
* `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:
* `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.
* `vavr` - Shows the support of [Vavr](https://www.vavr.io) collection types as return types for query methods.
+## Spring Data LDAP
+
+* `example` - Sample for Spring Data repositories to access an LDAP store.
+
## Spring Data MongoDB
* `aggregation` - Example project to showcase the MongoDB aggregation framework support.
@@ -46,14 +67,13 @@ We have separate folders for the samples of individual modules:
* `text-search` - Example project showing usage of MongoDB text search feature.
* `transactions` - Example project for imperative and reactive MongoDB 4.0 transaction support.
-## Spring Data REST
+## Spring Data Neo4j
-* `headers` - A sample showing the population of HTTP headers and the usage of them to perform conditional `GET` requests.
-* `multi-store` - A sample REST web-service based on both Spring Data JPA and Spring Data MongoDB.
-* `projections` - A sample REST web-service showing how to use projections.
-* `security` - A sample REST web-service secured using Spring Security.
-* `starbucks` - A sample REST web-service built with Spring Data REST and MongoDB.
-* `uri-customizations` - Example project to show URI customization capabilities.
+* `example` - Example to show basic node and relationship entities and repository usage.
+
+## Spring Data R2DBC
+
+* `example` - Basic usage of Spring Data R2DBC.
## Spring Data Redis
@@ -64,46 +84,26 @@ We have separate folders for the samples of individual modules:
* `sentinel` - Example for Redis Sentinel support.
* `streams` - Example for [Redis Streams](https://redis.io/topics/streams-intro) support.
+## Spring Data REST
+
+* `headers` - A sample showing the population of HTTP headers and the usage of them to perform conditional `GET` requests.
+* `multi-store` - A sample REST web-service based on both Spring Data JPA and Spring Data MongoDB.
+* `projections` - A sample REST web-service showing how to use projections.
+* `security` - A sample REST web-service secured using Spring Security.
+* `starbucks` - A sample REST web-service built with Spring Data REST and MongoDB.
+* `uri-customizations` - Example project to show URI customization capabilities.
+
## Spring Data for Apache Solr
* `example` - Example project for Spring Data repositories for Apache Solr.
* `managed-schema` - Example project to show managed schema integration.
-## Spring Data Elasticsearch
-
-* `example` - Example how to use basic text search, geo-spatial search and facets.
-* `rest` - Example how to use the High Level REST Client backing template and repository.
-* `reactive` - Example how to use reactive client, template and repository features.
-
-## Spring Data Neo4j
-
-* `example` - Example to show basic node and relationship entities and repository usage.
-
## Spring Data web support
* `projections` - Example for Spring Data web support for JSONPath and XPath expressions on projection interfaces.
* `querydsl` - Example for Spring Data Querydsl web integration (creating a `Predicate` from web requests).
* `web` - Example for Spring Data web integration (binding `Pageable` instances to Spring MVC controller methods, using interfaces to bind Spring MVC request payloads).
-## Spring Data for Apache Cassandra
-
-* `example` - Shows core Spring Data support for Apache Cassandra.
-* `java8` - Java 8 specific functionality like the support for JSR-310 types in object mapping.
-* `kotlin` - Example for using Cassandra with Kotlin.
-* `reactive` - Example project to show reactive template and repository support.
-
-## Spring Data LDAP
-
-* `example` - Sample for Spring Data repositories to access an LDAP store.
-
-## Spring Data JDBC
-
-* `basic` - Basic usage of Spring Data JDBC.
-
-## Spring Data R2DBC
-
-* `example` - Basic usage of Spring Data R2DBC.
-
## Miscellaneous
* `bom` - Example project how to use the Spring Data release train bom in non-Spring-Boot scenarios.
diff --git a/geode/events/pom.xml b/geode/events/pom.xml
index d7c2c297..51c10ee5 100755
--- a/geode/events/pom.xml
+++ b/geode/events/pom.xml
@@ -2,16 +2,14 @@
-
- example.springdata.geode
- spring-data-geode-examples
- 1.0-SNAPSHOT
-
- 4.0.0
- events
+ 4.0.0
-
+
+ org.springframework.data.examples
+ spring-data-geode-examples
+ 2.0.0.BUILD-SNAPSHOT
+
-
+ events
-
\ No newline at end of file
+
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/Address.java b/geode/events/src/main/java/example/springdata/geode/server/events/Address.java
index 5f8b8007..47300101 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/Address.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/Address.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
import lombok.Data;
@@ -29,6 +28,7 @@ import java.io.Serializable;
*/
@Data
public class Address implements Serializable {
+
private String street;
private String city;
private String country;
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/Customer.java b/geode/events/src/main/java/example/springdata/geode/server/events/Customer.java
index 1be4fe37..8fb20343 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/Customer.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/Customer.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
import lombok.Data;
@@ -48,4 +47,4 @@ public class Customer implements Serializable {
this.lastName = lastName;
this.addresses = Arrays.asList(addresses);
}
-}
\ No newline at end of file
+}
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/CustomerCacheWriter.java b/geode/events/src/main/java/example/springdata/geode/server/events/CustomerCacheWriter.java
index 8f31e674..11cfc198 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/CustomerCacheWriter.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/CustomerCacheWriter.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
import org.apache.geode.cache.CacheWriterException;
@@ -22,6 +21,9 @@ import org.apache.geode.cache.util.CacheWriterAdapter;
import org.apache.geode.internal.cache.EntryEventImpl;
import org.springframework.stereotype.Component;
+/**
+ * @author Patrick Johnson
+ */
@Component
public class CustomerCacheWriter extends CacheWriterAdapter {
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/CustomerRepository.java b/geode/events/src/main/java/example/springdata/geode/server/events/CustomerRepository.java
index 42b321a4..1613b694 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/CustomerRepository.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/CustomerRepository.java
@@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
import org.springframework.data.repository.CrudRepository;
+/**
+ * @author Patrick Johnson
+ */
public interface CustomerRepository extends CrudRepository {
}
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/EmailAddress.java b/geode/events/src/main/java/example/springdata/geode/server/events/EmailAddress.java
index 501f222b..1fc0b8ac 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/EmailAddress.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/EmailAddress.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
import lombok.Data;
@@ -28,10 +27,11 @@ import java.io.Serializable;
*/
@Data
public class EmailAddress implements Serializable {
+
private String value;
public EmailAddress(String value) {
this.value = value;
}
-}
\ No newline at end of file
+}
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/EventServer.java b/geode/events/src/main/java/example/springdata/geode/server/events/EventServer.java
index c687d8d6..3471f5a8 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/EventServer.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/EventServer.java
@@ -13,40 +13,41 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
-import org.apache.geode.cache.Region;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.ApplicationRunner;
-import org.springframework.boot.WebApplicationType;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.context.annotation.Bean;
-
import java.math.BigDecimal;
import java.util.List;
import java.util.Random;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
-@SpringBootApplication(scanBasePackageClasses = EventServerConfig.class)
+import lombok.extern.apachecommons.CommonsLog;
+import org.apache.geode.cache.Region;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.context.annotation.Bean;
+
+/**
+ * @author Patrick Johnson
+ */
+@SpringBootApplication
+@CommonsLog
public class EventServer {
- private Logger logger = LoggerFactory.getLogger(this.getClass());
-
public static void main(String[] args) {
- new SpringApplicationBuilder(EventServer.class)
- .web(WebApplicationType.NONE)
- .build()
- .run(args);
+ new SpringApplicationBuilder(EventServer.class).web(WebApplicationType.NONE).build().run(args);
}
@Bean
public ApplicationRunner runner(CustomerRepository customerRepository, OrderRepository orderRepository,
- ProductRepository productRepository, OrderProductSummaryRepository orderProductSummaryRepository, @Qualifier("Products") Region products) {
+ ProductRepository productRepository, OrderProductSummaryRepository orderProductSummaryRepository,
+ @Qualifier("Products") Region products) {
return args -> {
createCustomerData(customerRepository);
@@ -54,43 +55,37 @@ public class EventServer {
createOrders(productRepository, orderRepository);
- logger.info("Completed creating orders ");
+ log.info("Completed creating orders ");
- final List allForProductID = orderProductSummaryRepository.findAllForProductID(3L);
- allForProductID.forEach(orderProductSummary -> logger.info("orderProductSummary = " + orderProductSummary));
+ List allForProductID = orderProductSummaryRepository.findAllForProductID(3L);
+ allForProductID.forEach(orderProductSummary -> log.info("orderProductSummary = " + orderProductSummary));
};
}
private void createOrders(ProductRepository productRepository, OrderRepository orderRepository) {
Random random = new Random(System.nanoTime());
Address address = new Address("it", "doesn't", "matter");
- LongStream.rangeClosed(1, 10).forEach((orderId) ->
- LongStream.rangeClosed(1, 300).forEach((customerId) -> {
- Order order = new Order(orderId, customerId, address);
- IntStream.rangeClosed(0, random.nextInt(3) + 1).forEach((lineItemCount) -> {
- int quantity = random.nextInt(3) + 1;
- long productId = random.nextInt(3) + 1;
- order.add(new LineItem(productRepository.findById(productId).get(), quantity));
- });
- orderRepository.save(order);
- }));
+ LongStream.rangeClosed(1, 10).forEach((orderId) -> LongStream.rangeClosed(1, 300).forEach((customerId) -> {
+ Order order = new Order(orderId, customerId, address);
+ IntStream.rangeClosed(0, random.nextInt(3) + 1).forEach((lineItemCount) -> {
+ int quantity = random.nextInt(3) + 1;
+ long productId = random.nextInt(3) + 1;
+ order.add(new LineItem(productRepository.findById(productId).get(), quantity));
+ });
+ orderRepository.save(order);
+ }));
}
private void createProducts(ProductRepository productRepository) {
- productRepository.save(new Product(1L, "Apple iPod", new BigDecimal("99.99"),
- "An Apple portable music player"));
- productRepository.save(new Product(2L, "Apple iPad", new BigDecimal("499.99"),
- "An Apple tablet device"));
- Product macbook = new Product(3L, "Apple macBook", new BigDecimal("899.99"),
- "An Apple notebook computer");
+ productRepository.save(new Product(1L, "Apple iPod", new BigDecimal("99.99"), "An Apple portable music player"));
+ productRepository.save(new Product(2L, "Apple iPad", new BigDecimal("499.99"), "An Apple tablet device"));
+ Product macbook = new Product(3L, "Apple macBook", new BigDecimal("899.99"), "An Apple notebook computer");
macbook.addAttribute("warranty", "included");
productRepository.save(macbook);
}
private void createCustomerData(CustomerRepository customerRepository) {
- LongStream.rangeClosed(0, 300)
- .parallel()
- .forEach(customerId ->
- customerRepository.save(new Customer(customerId, new EmailAddress(customerId + "@2.com"), "John" + customerId, "Smith" + customerId)));
+ LongStream.rangeClosed(0, 300).parallel().forEach(customerId -> customerRepository.save(
+ new Customer(customerId, new EmailAddress(customerId + "@2.com"), "John" + customerId, "Smith" + customerId)));
}
-}
\ No newline at end of file
+}
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/EventServerConfig.java b/geode/events/src/main/java/example/springdata/geode/server/events/EventServerConfig.java
index f1c240c7..abc77899 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/EventServerConfig.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/EventServerConfig.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
import org.apache.geode.cache.Cache;
@@ -48,7 +47,7 @@ public class EventServerConfig {
@Bean
AsyncEventQueueFactoryBean orderAsyncEventQueue(GemFireCache gemFireCache, AsyncEventListener orderAsyncEventListener) {
- final AsyncEventQueueFactoryBean asyncEventQueueFactoryBean = new AsyncEventQueueFactoryBean((Cache) gemFireCache);
+ AsyncEventQueueFactoryBean asyncEventQueueFactoryBean = new AsyncEventQueueFactoryBean((Cache) gemFireCache);
asyncEventQueueFactoryBean.setBatchTimeInterval(1000);
asyncEventQueueFactoryBean.setBatchSize(5);
asyncEventQueueFactoryBean.setAsyncEventListener(orderAsyncEventListener);
@@ -57,7 +56,7 @@ public class EventServerConfig {
@Bean(name = "OrderProductSummary")
PartitionedRegionFactoryBean createOrderProductSummaryRegion(GemFireCache gemFireCache) {
- final PartitionedRegionFactoryBean partitionedRegionFactoryBean = new PartitionedRegionFactoryBean<>();
+ PartitionedRegionFactoryBean partitionedRegionFactoryBean = new PartitionedRegionFactoryBean<>();
partitionedRegionFactoryBean.setCache(gemFireCache);
partitionedRegionFactoryBean.setRegionName("OrderProductSummary");
partitionedRegionFactoryBean.setDataPolicy(DataPolicy.PARTITION);
@@ -66,7 +65,7 @@ public class EventServerConfig {
@Bean("Orders")
PartitionedRegionFactoryBean createOrderRegion(GemFireCache gemFireCache, AsyncEventQueue orderAsyncEventQueue) {
- final PartitionedRegionFactoryBean partitionedRegionFactoryBean = new PartitionedRegionFactoryBean<>();
+ PartitionedRegionFactoryBean partitionedRegionFactoryBean = new PartitionedRegionFactoryBean<>();
partitionedRegionFactoryBean.setCache(gemFireCache);
partitionedRegionFactoryBean.setRegionName("Orders");
partitionedRegionFactoryBean.setDataPolicy(DataPolicy.PARTITION);
@@ -77,7 +76,7 @@ public class EventServerConfig {
@Bean("Products")
ReplicatedRegionFactoryBean createProductRegion(GemFireCache gemFireCache, CacheListener loggingCacheListener,
CacheLoader productCacheLoader) {
- final ReplicatedRegionFactoryBean replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>();
+ ReplicatedRegionFactoryBean replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>();
replicatedRegionFactoryBean.setCache(gemFireCache);
replicatedRegionFactoryBean.setRegionName("Products");
replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE);
@@ -90,7 +89,7 @@ public class EventServerConfig {
ReplicatedRegionFactoryBean createCustomerRegion(GemFireCache gemFireCache,
CacheWriter customerCacheWriter,
CacheListener loggingCacheListener) {
- final ReplicatedRegionFactoryBean replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>();
+ ReplicatedRegionFactoryBean replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>();
replicatedRegionFactoryBean.setCache(gemFireCache);
replicatedRegionFactoryBean.setRegionName("Customers");
replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE);
@@ -98,4 +97,4 @@ public class EventServerConfig {
replicatedRegionFactoryBean.setCacheWriter(customerCacheWriter);
return replicatedRegionFactoryBean;
}
-}
\ No newline at end of file
+}
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/LineItem.java b/geode/events/src/main/java/example/springdata/geode/server/events/LineItem.java
index 0d353247..fba6241d 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/LineItem.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/LineItem.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
import lombok.Data;
@@ -45,4 +44,4 @@ public class LineItem implements Serializable {
public Long getProductId() {
return product.getId();
}
-}
\ No newline at end of file
+}
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/LoggingCacheListener.java b/geode/events/src/main/java/example/springdata/geode/server/events/LoggingCacheListener.java
index eb669e8b..aeeb4ff3 100644
--- a/geode/events/src/main/java/example/springdata/geode/server/events/LoggingCacheListener.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/LoggingCacheListener.java
@@ -13,32 +13,37 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
+import lombok.extern.apachecommons.CommonsLog;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.geode.cache.EntryEvent;
import org.apache.geode.cache.util.CacheListenerAdapter;
import org.springframework.stereotype.Component;
+/**
+ * @author Patrick Johnson
+ */
@Component
+@CommonsLog
public class LoggingCacheListener extends CacheListenerAdapter {
- private Log logger = LogFactory.getLog(LoggingCacheListener.class);
@Override
public void afterCreate(EntryEvent event) {
- logger.info("In region [" + event.getRegion().getName() + "] created key [" + event.getKey() + "] value [" + event.getNewValue() + "]");
+ log.info("In region [" + event.getRegion().getName() + "] created key [" + event.getKey() + "] value ["
+ + event.getNewValue() + "]");
}
@Override
public void afterDestroy(EntryEvent event) {
- logger.info("In region [" + event.getRegion().getName() + "] destroyed key [" + event.getKey() + "] ");
+ log.info("In region [" + event.getRegion().getName() + "] destroyed key [" + event.getKey() + "] ");
}
@Override
public void afterUpdate(EntryEvent event) {
- logger.info("In region [" + event.getRegion().getName() + "] updated key [" + event.getNewValue() + "] [oldValue [" + event.getOldValue() + "]] new value [" + event.getNewValue() + "]");
+ log.info("In region [" + event.getRegion().getName() + "] updated key [" + event.getNewValue() + "] [oldValue ["
+ + event.getOldValue() + "]] new value [" + event.getNewValue() + "]");
}
-}
\ No newline at end of file
+}
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/Order.java b/geode/events/src/main/java/example/springdata/geode/server/events/Order.java
index 9ff04a20..3847fd07 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/Order.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/Order.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
import lombok.Data;
@@ -34,6 +33,7 @@ import java.util.List;
@Data
@Region("Orders")
public class Order implements Serializable {
+
@Id
private Long id;
private Long customerId;
@@ -69,4 +69,4 @@ public class Order implements Serializable {
public void add(LineItem lineItem) {
lineItems.add(lineItem);
}
-}
\ No newline at end of file
+}
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/OrderAsyncQueueListener.java b/geode/events/src/main/java/example/springdata/geode/server/events/OrderAsyncQueueListener.java
index 37dbee2a..80469324 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/OrderAsyncQueueListener.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/OrderAsyncQueueListener.java
@@ -13,17 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.geode.cache.Region;
import org.apache.geode.cache.asyncqueue.AsyncEvent;
import org.apache.geode.cache.asyncqueue.AsyncEventListener;
-import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.List;
-
+/**
+ * @author Patrick Johnson
+ */
public class OrderAsyncQueueListener implements AsyncEventListener {
private Region summaryRegion;
@@ -34,9 +37,9 @@ public class OrderAsyncQueueListener implements AsyncEventListener {
@Override
public boolean processEvents(List list) {
- HashMap summaryMap = new HashMap<>();
+ Map summaryMap = new HashMap<>();
list.forEach(asyncEvent -> {
- final Order order = (Order) asyncEvent.getDeserializedValue();
+ Order order = (Order) asyncEvent.getDeserializedValue();
if (order != null) {
order.getLineItems().forEach(lineItem -> {
OrderProductSummary orderProductSummary = summaryMap.get(lineItem.getProductId());
@@ -50,14 +53,15 @@ public class OrderAsyncQueueListener implements AsyncEventListener {
});
summaryMap.forEach((orderProductSummaryKey, orderProductSummary) -> {
- final OrderProductSummary productSummary = summaryRegion.get(orderProductSummaryKey);
+ OrderProductSummary productSummary = summaryRegion.get(orderProductSummaryKey);
if (productSummary != null) {
- final BigDecimal newSummaryAmount = productSummary.getSummaryAmount().add(orderProductSummary.getSummaryAmount());
+ BigDecimal newSummaryAmount = productSummary.getSummaryAmount().add(orderProductSummary.getSummaryAmount());
summaryRegion.put(orderProductSummaryKey, new OrderProductSummary(orderProductSummaryKey, newSummaryAmount));
} else {
summaryRegion.put(orderProductSummaryKey, orderProductSummary);
}
});
+
return true;
}
-}
\ No newline at end of file
+}
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummary.java b/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummary.java
index f27512bd..b5c8e800 100644
--- a/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummary.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummary.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
import lombok.Data;
@@ -43,4 +42,4 @@ public class OrderProductSummary implements Serializable {
this.summaryKey = summaryKey;
this.summaryAmount = summaryAmount;
}
-}
\ No newline at end of file
+}
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummaryRepository.java b/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummaryRepository.java
index eb1525d4..d2d8f256 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummaryRepository.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/OrderProductSummaryRepository.java
@@ -13,16 +13,18 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
+import java.util.List;
+
import org.springframework.data.gemfire.mapping.annotation.Region;
import org.springframework.data.gemfire.repository.Query;
import org.springframework.data.gemfire.repository.query.annotation.Hint;
import org.springframework.data.repository.CrudRepository;
-import java.util.List;
-
+/**
+ * @author Patrick Johnson
+ */
@Region("OrderProductSummary")
public interface OrderProductSummaryRepository extends CrudRepository {
@Hint("emailAddressIndex")
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/OrderRepository.java b/geode/events/src/main/java/example/springdata/geode/server/events/OrderRepository.java
index be877760..6d391f09 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/OrderRepository.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/OrderRepository.java
@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
import org.springframework.data.repository.CrudRepository;
-public interface OrderRepository extends CrudRepository {
-}
+/**
+ * @author Patrick Johnson
+ */
+public interface OrderRepository extends CrudRepository {}
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/Product.java b/geode/events/src/main/java/example/springdata/geode/server/events/Product.java
index e9cb21e2..18c456c0 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/Product.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/Product.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
import lombok.Data;
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/ProductCacheLoader.java b/geode/events/src/main/java/example/springdata/geode/server/events/ProductCacheLoader.java
index 6aca0394..8d31fa1f 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/ProductCacheLoader.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/ProductCacheLoader.java
@@ -13,17 +13,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
-import com.github.javafaker.Faker;
+import lombok.SneakyThrows;
+
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+
import org.apache.geode.cache.CacheLoader;
import org.apache.geode.cache.CacheLoaderException;
import org.apache.geode.cache.LoaderHelper;
+
import org.springframework.stereotype.Component;
-import java.math.BigDecimal;
+import com.github.javafaker.Faker;
+/**
+ * @author Patrick Johnson
+ */
@Component
public class ProductCacheLoader implements CacheLoader {
private Faker faker = new Faker();
@@ -33,8 +40,9 @@ public class ProductCacheLoader implements CacheLoader {
return new Product((long) loaderHelper.getKey(), randomStringName(), randomPrice(), "");
}
+ @SneakyThrows
private BigDecimal randomPrice() {
- return new BigDecimal(faker.commerce().price());
+ return new BigDecimal(new DecimalFormat("#0.00").parse(faker.commerce().price()).toString());
}
private String randomStringName() {
diff --git a/geode/events/src/main/java/example/springdata/geode/server/events/ProductRepository.java b/geode/events/src/main/java/example/springdata/geode/server/events/ProductRepository.java
index 4f28a25f..efb9484d 100755
--- a/geode/events/src/main/java/example/springdata/geode/server/events/ProductRepository.java
+++ b/geode/events/src/main/java/example/springdata/geode/server/events/ProductRepository.java
@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
import org.springframework.data.repository.CrudRepository;
-public interface ProductRepository extends CrudRepository {
-}
+/**
+ * @author Patrick Johnson
+ */
+public interface ProductRepository extends CrudRepository {}
diff --git a/geode/events/src/test/java/example/springdata/geode/server/events/EventServerTests.java b/geode/events/src/test/java/example/springdata/geode/server/events/EventServerTests.java
index d6840d81..f93c9e91 100755
--- a/geode/events/src/test/java/example/springdata/geode/server/events/EventServerTests.java
+++ b/geode/events/src/test/java/example/springdata/geode/server/events/EventServerTests.java
@@ -13,32 +13,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.events;
+import static org.assertj.core.api.Assertions.*;
+
import org.apache.geode.cache.Cache;
import org.junit.Test;
import org.junit.runner.RunWith;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
-import static org.assertj.core.api.Assertions.assertThat;
-
+/**
+ * @author Patrick Johnson
+ */
@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = EventServer.class)
-@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
+@SpringBootTest
public class EventServerTests {
- @Autowired
- Cache cache;
+ @Autowired Cache cache;
- @Autowired
- private ProductRepository productRepository;
+ @Autowired private ProductRepository productRepository;
- @Autowired
- private OrderProductSummaryRepository orderProductSummaryRepository;
+ @Autowired private OrderProductSummaryRepository orderProductSummaryRepository;
@Test
public void asyncEventQueueEasConfiguredCorrectly() {
@@ -47,9 +45,12 @@ public class EventServerTests {
@Test
public void productCacheLoaderWorks() {
+
long size = productRepository.count();
+
assertThat(this.productRepository.findById(777L)).isNotNull();
assertThat(productRepository.count()).isEqualTo(size + 1);
+
productRepository.deleteById(777L);
}
-}
\ No newline at end of file
+}
diff --git a/geode/expiration-eviction/pom.xml b/geode/expiration-eviction/pom.xml
index 6d1bd957..7d15c469 100755
--- a/geode/expiration-eviction/pom.xml
+++ b/geode/expiration-eviction/pom.xml
@@ -2,22 +2,22 @@
-
- example.springdata.geode
- spring-data-geode-examples
- 1.0-SNAPSHOT
-
- 4.0.0
+ 4.0.0
- expiration-eviction
+
+ org.springframework.data.examples
+ spring-data-geode-examples
+ 2.0.0.BUILD-SNAPSHOT
+
-
-
- com.jayway.awaitility
- awaitility
- 1.7.0
-
-
+ expiration-eviction
+
+
+ org.awaitility
+ awaitility
+ test
+
+
-
\ No newline at end of file
+
diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Address.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Address.java
index 330611ca..a92bedc9 100755
--- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Address.java
+++ b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Address.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.expiration.eviction;
import lombok.Data;
@@ -29,6 +28,7 @@ import java.io.Serializable;
*/
@Data
public class Address implements Serializable {
+
private String street;
private String city;
private String country;
diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomCustomerExpiry.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomCustomerExpiry.java
index 9f68657a..ceccc560 100755
--- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomCustomerExpiry.java
+++ b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomCustomerExpiry.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.expiration.eviction;
import org.apache.geode.cache.CustomExpiry;
@@ -21,10 +20,12 @@ import org.apache.geode.cache.ExpirationAction;
import org.apache.geode.cache.ExpirationAttributes;
import org.apache.geode.cache.Region;
-
+/**
+ * @author Patrick Johnson
+ */
public class CustomCustomerExpiry implements CustomExpiry {
- private int timeout;
+ private final int timeout;
public CustomCustomerExpiry(int timeout) {
this.timeout = timeout;
@@ -37,4 +38,4 @@ public class CustomCustomerExpiry implements CustomExpiry {
}
return null;
}
-}
\ No newline at end of file
+}
diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Customer.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Customer.java
index 7da9f4c3..260a9037 100755
--- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Customer.java
+++ b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Customer.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.expiration.eviction;
import lombok.Data;
@@ -48,4 +47,4 @@ public class Customer implements Serializable {
this.lastName = lastName;
this.addresses = Arrays.asList(addresses);
}
-}
\ No newline at end of file
+}
diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomerRepository.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomerRepository.java
index a0d0f0d8..8de6532b 100755
--- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomerRepository.java
+++ b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/CustomerRepository.java
@@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.expiration.eviction;
import org.springframework.data.gemfire.mapping.annotation.Region;
import org.springframework.data.repository.CrudRepository;
+/**
+ * @author Patrick Johnson
+ */
@Region("Customers")
-public interface CustomerRepository extends CrudRepository {
-}
+public interface CustomerRepository extends CrudRepository {}
diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/EmailAddress.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/EmailAddress.java
index 6d3780b9..145cacab 100755
--- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/EmailAddress.java
+++ b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/EmailAddress.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.expiration.eviction;
import lombok.Data;
@@ -28,10 +27,11 @@ import java.io.Serializable;
*/
@Data
public class EmailAddress implements Serializable {
+
private String value;
public EmailAddress(String value) {
this.value = value;
}
-}
\ No newline at end of file
+}
diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServer.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServer.java
index e1ec74c8..fb1fd4db 100755
--- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServer.java
+++ b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServer.java
@@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.expiration.eviction;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
-@SpringBootApplication(scanBasePackageClasses = ExpirationEvictionServerConfig.class)
+/**
+ * @author Patrick Johnson
+ */
+@SpringBootApplication
public class ExpirationEvictionServer {
public static void main(String[] args) {
diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerConfig.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerConfig.java
index 8e574900..2321bdf8 100755
--- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerConfig.java
+++ b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerConfig.java
@@ -13,14 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.expiration.eviction;
-import com.github.javafaker.Faker;
import org.apache.geode.cache.CustomExpiry;
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Scope;
+
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -34,16 +33,19 @@ import org.springframework.data.gemfire.eviction.EvictionActionType;
import org.springframework.data.gemfire.eviction.EvictionPolicyType;
import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories;
+import com.github.javafaker.Faker;
+
+/**
+ * @author Patrick Johnson
+ */
@Configuration
@CacheServerApplication(logLevel = "error")
@EnableLocator
@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class)
@EnableExpiration
@Import(ExpirationPolicyConfig.class)
-@EnableEviction(policies = @EnableEviction.EvictionPolicy(regionNames = "Orders",
- maximum = 10,
- action = EvictionActionType.LOCAL_DESTROY,
- type = EvictionPolicyType.ENTRY_COUNT))
+@EnableEviction(policies = @EnableEviction.EvictionPolicy(regionNames = "Orders", maximum = 10,
+ action = EvictionActionType.LOCAL_DESTROY, type = EvictionPolicyType.ENTRY_COUNT))
public class ExpirationEvictionServerConfig {
@Bean
@@ -63,9 +65,9 @@ public class ExpirationEvictionServerConfig {
@Bean("Products")
public ReplicatedRegionFactoryBean createProductRegion(GemFireCache gemFireCache,
- @Qualifier("IDLE") CustomExpiry idleExpiry,
- @Qualifier("TTL") CustomExpiry ttlExpiry) {
- final ReplicatedRegionFactoryBean regionFactoryBean = new ReplicatedRegionFactoryBean<>();
+ @Qualifier("IDLE") CustomExpiry idleExpiry,
+ @Qualifier("TTL") CustomExpiry ttlExpiry) {
+ ReplicatedRegionFactoryBean regionFactoryBean = new ReplicatedRegionFactoryBean<>();
regionFactoryBean.setCache(gemFireCache);
regionFactoryBean.setScope(Scope.DISTRIBUTED_ACK);
regionFactoryBean.setDataPolicy(DataPolicy.REPLICATE);
@@ -77,7 +79,7 @@ public class ExpirationEvictionServerConfig {
@Bean("Customers")
public ReplicatedRegionFactoryBean createCustomerRegion(GemFireCache gemFireCache) {
- final ReplicatedRegionFactoryBean regionFactoryBean = new ReplicatedRegionFactoryBean<>();
+ ReplicatedRegionFactoryBean regionFactoryBean = new ReplicatedRegionFactoryBean<>();
regionFactoryBean.setCache(gemFireCache);
regionFactoryBean.setScope(Scope.DISTRIBUTED_ACK);
regionFactoryBean.setDataPolicy(DataPolicy.REPLICATE);
@@ -87,7 +89,7 @@ public class ExpirationEvictionServerConfig {
@Bean("Orders")
public ReplicatedRegionFactoryBean createOrderRegion(GemFireCache gemFireCache) {
- final ReplicatedRegionFactoryBean regionFactoryBean = new ReplicatedRegionFactoryBean<>();
+ ReplicatedRegionFactoryBean regionFactoryBean = new ReplicatedRegionFactoryBean<>();
regionFactoryBean.setCache(gemFireCache);
regionFactoryBean.setScope(Scope.DISTRIBUTED_ACK);
regionFactoryBean.setDataPolicy(DataPolicy.REPLICATE);
diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationPolicyConfig.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationPolicyConfig.java
index ea5b5cdf..4cd30678 100644
--- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationPolicyConfig.java
+++ b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ExpirationPolicyConfig.java
@@ -20,12 +20,14 @@ import org.springframework.context.annotation.Profile;
import org.springframework.data.gemfire.config.annotation.EnableExpiration;
import org.springframework.data.gemfire.expiration.ExpirationActionType;
+/**
+ * @author Patrick Johnson
+ */
@Profile("!default")
@Configuration
@EnableExpiration(policies = {
- @EnableExpiration.ExpirationPolicy(timeout = 4, action = ExpirationActionType.DESTROY,
- regionNames = {"Customers"}, types = {EnableExpiration.ExpirationType.TIME_TO_LIVE}),
@EnableExpiration.ExpirationPolicy(timeout = 2, action = ExpirationActionType.DESTROY,
- regionNames = {"Customers"}, types = {EnableExpiration.ExpirationType.IDLE_TIMEOUT})})
-public class ExpirationPolicyConfig {
-}
+ regionNames = { "Customers" }, types = { EnableExpiration.ExpirationType.TIME_TO_LIVE }),
+ @EnableExpiration.ExpirationPolicy(timeout = 1, action = ExpirationActionType.DESTROY,
+ regionNames = { "Customers" }, types = { EnableExpiration.ExpirationType.IDLE_TIMEOUT }) })
+public class ExpirationPolicyConfig {}
diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Order.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Order.java
index 1cde9eb5..f24277a6 100755
--- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Order.java
+++ b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Order.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.expiration.eviction;
import lombok.Data;
@@ -31,10 +30,11 @@ import java.io.Serializable;
* @author Patrick Johnson
*/
@Data
-@IdleTimeoutExpiration(action = "DESTROY", timeout = "2")
-@TimeToLiveExpiration(action = "DESTROY", timeout = "4")
+@IdleTimeoutExpiration(action = "DESTROY", timeout = "1")
+@TimeToLiveExpiration(action = "DESTROY", timeout = "2")
@Region("Orders")
public class Order implements Serializable {
+
@Id
private Long id;
private Long total;
@@ -47,4 +47,4 @@ public class Order implements Serializable {
this.billingAddress = address;
this.shippingAddress = address;
}
-}
\ No newline at end of file
+}
diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/OrderRepository.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/OrderRepository.java
index 3f8d18cf..5e7787f5 100644
--- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/OrderRepository.java
+++ b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/OrderRepository.java
@@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.expiration.eviction;
import org.springframework.data.gemfire.mapping.annotation.Region;
import org.springframework.data.repository.CrudRepository;
+/**
+ * @author Patrick Johnson
+ */
@Region("Orders")
-public interface OrderRepository extends CrudRepository {
-}
+public interface OrderRepository extends CrudRepository {}
diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Product.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Product.java
index 9b766c0d..6c46ed4d 100755
--- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Product.java
+++ b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/Product.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.expiration.eviction;
import lombok.Data;
diff --git a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ProductRepository.java b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ProductRepository.java
index 49f5d48d..51682fd9 100644
--- a/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ProductRepository.java
+++ b/geode/expiration-eviction/src/main/java/example/springdata/geode/server/expiration/eviction/ProductRepository.java
@@ -13,10 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.expiration.eviction;
import org.springframework.data.repository.CrudRepository;
-public interface ProductRepository extends CrudRepository {
-}
+/**
+ * @author Patrick Johnson
+ */
+public interface ProductRepository extends CrudRepository {}
diff --git a/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/EntityDefinedExpirationTests.java b/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/EntityDefinedExpirationTests.java
index 209b9fd3..b3f656d5 100644
--- a/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/EntityDefinedExpirationTests.java
+++ b/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/EntityDefinedExpirationTests.java
@@ -15,70 +15,68 @@
*/
package example.springdata.geode.server.expiration.eviction;
-import com.github.javafaker.Faker;
-import com.jayway.awaitility.Awaitility;
+import static org.assertj.core.api.Assertions.*;
+
+import lombok.extern.apachecommons.CommonsLog;
+
+import java.time.Instant;
+import java.util.concurrent.TimeUnit;
+
+import org.awaitility.Awaitility;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
-
-import static org.assertj.core.api.Assertions.assertThat;
+import com.github.javafaker.Faker;
+/**
+ * @author Patrick Johnson
+ */
@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = ExpirationEvictionServer.class)
+@SpringBootTest
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
+@CommonsLog
public class EntityDefinedExpirationTests {
- @Autowired
- private OrderRepository orderRepository;
+ @Autowired private OrderRepository orderRepository;
- @Autowired
- Faker faker;
-
- private Logger logger = LoggerFactory.getLogger(this.getClass());
+ @Autowired Faker faker;
@Test
public void entityDefinedExpirationIsConfiguredCorrectly() {
- orderRepository.save(new Order(1L, 50L, new Address(faker.address().streetAddress(), faker.address().city(), faker.address().country())));
+
+ orderRepository.save(new Order(1L, 50L,
+ new Address(faker.address().streetAddress(), faker.address().city(), faker.address().country())));
assertThat(orderRepository.count()).isEqualTo(1);
- final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss:SSS");
- logger.info("Starting TTL wait period: " + simpleDateFormat.format(new Date()));
- //Due to the constant "getting" of the entry, the idle expiry timeout will not be met and the time-to-live
+ log.info("Starting TTL wait period: " + Instant.now());
+ // Due to the constant "getting" of the entry, the idle expiry timeout will not be met and the time-to-live
// will be used.
- Awaitility.await()
- .pollInterval(1, TimeUnit.SECONDS)
- .atMost(10, TimeUnit.SECONDS)
+ Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(10, TimeUnit.SECONDS)
.until(() -> !orderRepository.findById(1L).isPresent());
assertThat(orderRepository.count()).isEqualTo(0);
- logger.info("Ending TTL wait period: " + simpleDateFormat.format(new Date()));
+ log.info("Ending TTL wait period: " + Instant.now());
- orderRepository.save(new Order(1L, 50L, new Address(faker.address().streetAddress(), faker.address().city(), faker.address().country())));
+ orderRepository.save(new Order(1L, 50L,
+ new Address(faker.address().streetAddress(), faker.address().city(), faker.address().country())));
assertThat(orderRepository.count()).isEqualTo(1);
- logger.info("Starting Idle wait period: " + simpleDateFormat.format(new Date()));
+ log.info("Starting Idle wait period: " + Instant.now());
- //Due to the delay in "getting" the entry, the idle timeout of 2s should delete the entry.
- Awaitility.await()
- .pollDelay(2, TimeUnit.SECONDS)
- .pollInterval(100, TimeUnit.MILLISECONDS)
- .atMost(10, TimeUnit.SECONDS)
- .until(() -> !orderRepository.findById(1L).isPresent());
+ // Due to the delay in "getting" the entry, the idle timeout of 2s should delete the entry.
+ Awaitility.await().pollDelay(2, TimeUnit.SECONDS).pollInterval(100, TimeUnit.MILLISECONDS)
+ .atMost(10, TimeUnit.SECONDS).until(() -> !orderRepository.findById(1L).isPresent());
assertThat(orderRepository.count()).isEqualTo(0);
- logger.info("Ending Idle wait period: " + simpleDateFormat.format(new Date()));
+ log.info("Ending Idle wait period: " + Instant.now());
}
}
diff --git a/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerTests.java b/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerTests.java
index 0b29c798..f3ef7a64 100755
--- a/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerTests.java
+++ b/geode/expiration-eviction/src/test/java/example/springdata/geode/server/expiration/eviction/ExpirationEvictionServerTests.java
@@ -13,68 +13,64 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.server.expiration.eviction;
-import com.github.javafaker.Faker;
-import com.jayway.awaitility.Awaitility;
+import static org.assertj.core.api.Assertions.*;
+
+import lombok.extern.apachecommons.CommonsLog;
+
+import java.math.BigDecimal;
+import java.time.Instant;
+import java.util.concurrent.TimeUnit;
+
+import org.awaitility.Awaitility;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
-import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
-
-import static org.assertj.core.api.Assertions.assertThat;
+import com.github.javafaker.Faker;
+/**
+ * @author Patrick Johnson
+ */
@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = ExpirationEvictionServer.class)
-@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
+@SpringBootTest(classes = ExpirationEvictionServer.class)
@ActiveProfiles("expiration_policy")
+@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
+@CommonsLog
public class ExpirationEvictionServerTests {
- @Autowired
- private CustomerRepository customerRepository;
+ @Autowired private CustomerRepository customerRepository;
- @Autowired
- private ProductRepository productRepository;
+ @Autowired private ProductRepository productRepository;
- @Autowired
- private OrderRepository orderRepository;
+ @Autowired private OrderRepository orderRepository;
- @Autowired
- Faker faker;
-
- private Logger logger = LoggerFactory.getLogger(this.getClass());
+ @Autowired Faker faker;
@Test
public void cacheDefinedExpirationIsConfiguredCorrectly() {
+
customerRepository.save(new Customer(1L, new EmailAddress(faker.internet().emailAddress()),
faker.name().firstName(), faker.name().lastName(),
new Address(faker.address().streetAddress(), faker.address().city(), faker.address().country())));
assertThat(customerRepository.count()).isEqualTo(1);
- final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss:SSS");
- logger.info("Starting TTL wait period: " + simpleDateFormat.format(new Date()));
- //Due to the constant "getting" of the entry, the idle expiry timeout will not be met and the time-to-live
+ log.info(String.format("Starting TTL wait period: %s", Instant.now()));
+ // Due to the constant "getting" of the entry, the idle expiry timeout will not be met and the time-to-live
// will be used.
- Awaitility.await()
- .pollInterval(1, TimeUnit.SECONDS)
- .atMost(10, TimeUnit.SECONDS)
+ Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(10, TimeUnit.SECONDS)
.until(() -> !customerRepository.findById(1L).isPresent());
assertThat(customerRepository.count()).isEqualTo(0);
- logger.info("Ending TTL wait period: " + simpleDateFormat.format(new Date()));
+ log.info(String.format("Ending TTL wait period: %s", Instant.now()));
customerRepository.save(new Customer(1L, new EmailAddress(faker.internet().emailAddress()),
faker.name().firstName(), faker.name().lastName(),
@@ -82,18 +78,15 @@ public class ExpirationEvictionServerTests {
assertThat(customerRepository.count()).isEqualTo(1);
- logger.info("Starting Idle wait period: " + simpleDateFormat.format(new Date()));
+ log.info(String.format("Starting Idle wait period: %s", Instant.now()));
- //Due to the delay in "getting" the entry, the idle timeout of 2s should delete the entry.
- Awaitility.await()
- .pollDelay(2, TimeUnit.SECONDS)
- .pollInterval(100, TimeUnit.MILLISECONDS)
- .atMost(10, TimeUnit.SECONDS)
- .until(() -> !customerRepository.findById(1L).isPresent());
+ // Due to the delay in "getting" the entry, the idle timeout of 2s should delete the entry.
+ Awaitility.await().pollDelay(2, TimeUnit.SECONDS).pollInterval(100, TimeUnit.MILLISECONDS)
+ .atMost(10, TimeUnit.SECONDS).until(() -> !customerRepository.findById(1L).isPresent());
assertThat(customerRepository.count()).isEqualTo(0);
- logger.info("Ending Idle wait period: " + simpleDateFormat.format(new Date()));
+ log.info(String.format("Ending Idle wait period: %s", Instant.now()));
}
@Test
@@ -102,36 +95,29 @@ public class ExpirationEvictionServerTests {
assertThat(productRepository.count()).isEqualTo(1);
-
- final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss:SSS");
- logger.info("Starting TTL wait period: " + simpleDateFormat.format(new Date()));
- //Due to the constant "getting" of the entry, the idle expiry timeout will not be met and the time-to-live
+ log.info(String.format("Starting TTL wait period: %s", Instant.now()));
+ // Due to the constant "getting" of the entry, the idle expiry timeout will not be met and the time-to-live
// will be used.
- Awaitility.await()
- .pollInterval(1, TimeUnit.SECONDS)
- .atMost(10, TimeUnit.SECONDS)
+ Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(10, TimeUnit.SECONDS)
.until(() -> !productRepository.findById(3L).isPresent());
assertThat(productRepository.count()).isEqualTo(0);
- logger.info("Ending TTL wait period: " + simpleDateFormat.format(new Date()));
+ log.info("Ending TTL wait period: " + Instant.now());
productRepository.save(new Product(3L, "MacBook Pro", BigDecimal.valueOf(20), "A cool computing device"));
assertThat(productRepository.count()).isEqualTo(1);
- logger.info("Starting Idle wait period: " + simpleDateFormat.format(new Date()));
+ log.info(String.format("Starting Idle wait period: %s", Instant.now()));
- //Due to the delay in "getting" the entry, the idle timeout of 2s should delete the entry.
- Awaitility.await()
- .pollDelay(2, TimeUnit.SECONDS)
- .pollInterval(100, TimeUnit.MILLISECONDS)
- .atMost(10, TimeUnit.SECONDS)
- .until(() -> !productRepository.findById(3L).isPresent());
+ // Due to the delay in "getting" the entry, the idle timeout of 2s should delete the entry.
+ Awaitility.await().pollDelay(2, TimeUnit.SECONDS).pollInterval(100, TimeUnit.MILLISECONDS)
+ .atMost(10, TimeUnit.SECONDS).until(() -> !productRepository.findById(3L).isPresent());
assertThat(productRepository.count()).isEqualTo(0);
- logger.info("Ending Idle wait period: " + simpleDateFormat.format(new Date()));
+ log.info(String.format("Ending Idle wait period: %s", Instant.now()));
}
@Test
@@ -139,10 +125,11 @@ public class ExpirationEvictionServerTests {
final int evictionThreshold = 10;
for (long i = 0; i < evictionThreshold + 1; i++) {
- orderRepository.save(new Order(i, i, new Address(faker.address().streetName(), faker.address().city(), faker.address().country())));
+ orderRepository.save(new Order(i, i,
+ new Address(faker.address().streetName(), faker.address().city(), faker.address().country())));
}
assertThat(orderRepository.count()).isEqualTo(evictionThreshold);
orderRepository.deleteAll();
}
-}
\ No newline at end of file
+}
diff --git a/geode/function-invocation/pom.xml b/geode/function-invocation/pom.xml
index 79694888..7f4dc59d 100755
--- a/geode/function-invocation/pom.xml
+++ b/geode/function-invocation/pom.xml
@@ -2,17 +2,14 @@
-
- example.springdata.geode
- spring-data-geode-examples
- 1.0-SNAPSHOT
-
- 4.0.0
- function-invocation
- 1.0-SNAPSHOT
+ 4.0.0
-
+
+ org.springframework.data.examples
+ spring-data-geode-examples
+ 2.0.0.BUILD-SNAPSHOT
+
-
+ function-invocation
-
\ No newline at end of file
+
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Address.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Address.java
index ccdf1fdd..74cb91d3 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Address.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Address.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function;
import lombok.Data;
@@ -29,6 +28,7 @@ import java.io.Serializable;
*/
@Data
public class Address implements Serializable {
+
private String street;
private String city;
private String country;
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Customer.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Customer.java
index e24b3d92..15eff178 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Customer.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Customer.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function;
import lombok.Data;
@@ -55,4 +54,4 @@ public class Customer implements Serializable {
public void add(Address address) {
this.addresses.add(address);
}
-}
\ No newline at end of file
+}
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/EmailAddress.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/EmailAddress.java
index 145ed6d4..692f5fd9 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/EmailAddress.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/EmailAddress.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function;
import lombok.Data;
@@ -28,10 +27,11 @@ import java.io.Serializable;
*/
@Data
public class EmailAddress implements Serializable {
+
private String value;
public EmailAddress(String value) {
this.value = value;
}
-}
\ No newline at end of file
+}
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/LineItem.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/LineItem.java
index 4055db5b..d3d8f966 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/LineItem.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/LineItem.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function;
import lombok.Data;
@@ -41,4 +40,4 @@ public class LineItem implements Serializable {
public BigDecimal calcTotal() {
return product.getPrice().multiply(BigDecimal.valueOf(amount));
}
-}
\ No newline at end of file
+}
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Order.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Order.java
index 69550e8b..fe16f46c 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Order.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Order.java
@@ -34,6 +34,7 @@ import java.util.List;
@Data
@Region("Orders")
public class Order implements Serializable {
+
@Id
private Long id;
private Long customerId;
@@ -70,4 +71,4 @@ public class Order implements Serializable {
public void add(LineItem lineItem) {
lineItems.add(lineItem);
}
-}
\ No newline at end of file
+}
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Product.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Product.java
index c10dfb0e..95c2c556 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Product.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/Product.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function;
import lombok.Data;
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerFunctionExecutions.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerFunctionExecutions.java
index 7ad8f320..16c73913 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerFunctionExecutions.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerFunctionExecutions.java
@@ -13,18 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.client;
import example.springdata.geode.client.function.Customer;
-import org.springframework.data.gemfire.function.annotation.FunctionId;
-import org.springframework.data.gemfire.function.annotation.OnRegion;
import java.util.List;
+import org.springframework.data.gemfire.function.annotation.FunctionId;
+import org.springframework.data.gemfire.function.annotation.OnRegion;
+
+/**
+ * @author Patrick Johnson
+ */
@OnRegion(region = "Customers")
public interface CustomerFunctionExecutions {
@FunctionId("listConsumersForEmailAddressesFnc")
List> listAllCustomersForEmailAddress(String... emailAddresses);
-}
\ No newline at end of file
+}
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerRepository.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerRepository.java
index b2154535..89ca6c53 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerRepository.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/CustomerRepository.java
@@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.client;
import example.springdata.geode.client.function.Customer;
+
+import java.util.List;
+
import org.springframework.data.gemfire.mapping.annotation.ClientRegion;
import org.springframework.data.gemfire.repository.Query;
import org.springframework.data.gemfire.repository.query.annotation.Hint;
@@ -24,8 +26,9 @@ import org.springframework.data.gemfire.repository.query.annotation.Limit;
import org.springframework.data.gemfire.repository.query.annotation.Trace;
import org.springframework.data.repository.CrudRepository;
-import java.util.List;
-
+/**
+ * @author Patrick Johnson
+ */
@ClientRegion("Customers")
public interface CustomerRepository extends CrudRepository {
@@ -39,4 +42,4 @@ public interface CustomerRepository extends CrudRepository {
@Limit(100)
@Query("select * from /Customers customer where customer.firstName = $1")
List findByFirstNameUsingIndex(String firstName);
-}
\ No newline at end of file
+}
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/FunctionInvocationClientApplicationConfig.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/FunctionInvocationClientApplicationConfig.java
index ddc0ff89..cf073ed1 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/FunctionInvocationClientApplicationConfig.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/FunctionInvocationClientApplicationConfig.java
@@ -13,14 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.client;
import example.springdata.geode.client.function.Customer;
import example.springdata.geode.client.function.Order;
import example.springdata.geode.client.function.Product;
+
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.client.ClientRegionShortcut;
+
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
@@ -35,11 +36,11 @@ import org.springframework.data.gemfire.transaction.config.EnableGemfireCacheTra
* @author Udo Kohlmeyer
* @author Patrick Johnson
*/
-
@Configuration
@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class)
@EnableGemfireFunctionExecutions(basePackageClasses = CustomerFunctionExecutions.class)
-@ClientCacheApplication(name = "FunctionInvocationClient", logLevel = "error", pingInterval = 5000L, readTimeout = 15000, retryAttempts = 1)
+@ClientCacheApplication(name = "FunctionInvocationClient", logLevel = "error", pingInterval = 5000L,
+ readTimeout = 15000, retryAttempts = 1)
@EnableGemfireCacheTransactions
public class FunctionInvocationClientApplicationConfig {
@@ -69,4 +70,4 @@ public class FunctionInvocationClientApplicationConfig {
clientRegionFactoryBean.setShortcut(ClientRegionShortcut.PROXY);
return clientRegionFactoryBean;
}
-}
\ No newline at end of file
+}
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderFunctionExecutions.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderFunctionExecutions.java
index 38c41541..c5407f2e 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderFunctionExecutions.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderFunctionExecutions.java
@@ -13,18 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.client;
-import org.springframework.data.gemfire.function.annotation.FunctionId;
-import org.springframework.data.gemfire.function.annotation.OnRegion;
-
import java.math.BigDecimal;
import java.util.List;
+import org.springframework.data.gemfire.function.annotation.FunctionId;
+import org.springframework.data.gemfire.function.annotation.OnRegion;
+
+/**
+ * @author Patrick Johnson
+ */
@OnRegion(region = "Orders")
public interface OrderFunctionExecutions {
@FunctionId("sumPricesForAllProductsForOrderFnc")
List sumPricesForAllProductsForOrder(Long orderId);
-}
\ No newline at end of file
+}
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderRepository.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderRepository.java
index 22b80fc5..485ce7f4 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderRepository.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/OrderRepository.java
@@ -13,14 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.client;
import example.springdata.geode.client.function.Order;
+
import org.springframework.data.gemfire.mapping.annotation.ClientRegion;
import org.springframework.data.repository.CrudRepository;
+/**
+ * @author Patrick Johnson
+ */
@ClientRegion("Orders")
-public interface OrderRepository extends CrudRepository {
-
-}
+public interface OrderRepository extends CrudRepository {}
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductFunctionExecutions.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductFunctionExecutions.java
index ef9cac47..15e71e50 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductFunctionExecutions.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductFunctionExecutions.java
@@ -13,18 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.client;
-import org.springframework.data.gemfire.function.annotation.FunctionId;
-import org.springframework.data.gemfire.function.annotation.OnRegion;
-
import java.math.BigDecimal;
import java.util.List;
+import org.springframework.data.gemfire.function.annotation.FunctionId;
+import org.springframework.data.gemfire.function.annotation.OnRegion;
+
+/**
+ * @author Patrick Johnson
+ */
@OnRegion(region = "Products")
public interface ProductFunctionExecutions {
@FunctionId("sumPricesForAllProductsFnc")
List sumPricesForAllProducts();
-}
\ No newline at end of file
+}
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductRepository.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductRepository.java
index c7159880..109fc277 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductRepository.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/client/ProductRepository.java
@@ -13,14 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.client;
import example.springdata.geode.client.function.Product;
+
import org.springframework.data.gemfire.mapping.annotation.ClientRegion;
import org.springframework.data.repository.CrudRepository;
+/**
+ * @author Patrick Johnson
+ */
@ClientRegion("Products")
-public interface ProductRepository extends CrudRepository {
-
-}
+public interface ProductRepository extends CrudRepository {}
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/CustomerFunctions.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/CustomerFunctions.java
index 48642fbc..4ad9e654 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/CustomerFunctions.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/CustomerFunctions.java
@@ -13,25 +13,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.server;
import example.springdata.geode.client.function.Customer;
-import org.springframework.data.gemfire.function.annotation.GemfireFunction;
-import org.springframework.data.gemfire.function.annotation.RegionData;
-import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import org.springframework.data.gemfire.function.annotation.GemfireFunction;
+import org.springframework.data.gemfire.function.annotation.RegionData;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Patrick Johnson
+ */
@Component
public class CustomerFunctions {
- @GemfireFunction(id = "listConsumersForEmailAddressesFnc", HA = true, optimizeForWrite = true, batchSize = 3, hasResult = true)
+ @GemfireFunction(id = "listConsumersForEmailAddressesFnc", HA = true, optimizeForWrite = true, batchSize = 3,
+ hasResult = true)
public List listAllCustomersForEmailAddress(@RegionData Map customerData,
- String... emailAddresses) {
+ String... emailAddresses) {
List emailAddressesAsList = Arrays.asList(emailAddresses);
List collect = customerData.values().parallelStream()
.filter((customer) -> emailAddressesAsList.contains(customer.getEmailAddress().getValue()))
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServer.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServer.java
index d93642ee..3327fd4d 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServer.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServer.java
@@ -13,14 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.server;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
-@SpringBootApplication(scanBasePackageClasses = FunctionServerApplicationConfig.class)
+/**
+ * @author Patrick Johnson
+ */
+@SpringBootApplication
public class FunctionServer {
public static void main(String[] args) {
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServerApplicationConfig.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServerApplicationConfig.java
index 62830acb..5c1bf769 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServerApplicationConfig.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/FunctionServerApplicationConfig.java
@@ -13,16 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.server;
import example.springdata.geode.client.function.Customer;
import example.springdata.geode.client.function.Order;
import example.springdata.geode.client.function.Product;
import example.springdata.geode.client.function.client.CustomerRepository;
+
import org.apache.geode.cache.DataPolicy;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Scope;
+
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -34,6 +35,9 @@ import org.springframework.data.gemfire.config.annotation.EnableManager;
import org.springframework.data.gemfire.function.config.EnableGemfireFunctions;
import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories;
+/**
+ * @author Patrick Johnson
+ */
@Configuration
@ComponentScan(basePackageClasses = CustomerFunctions.class)
@EnableGemfireFunctions
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/OrderFunctions.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/OrderFunctions.java
index 686395e6..09ba5e06 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/OrderFunctions.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/OrderFunctions.java
@@ -13,17 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.server;
import example.springdata.geode.client.function.Order;
-import org.springframework.data.gemfire.function.annotation.GemfireFunction;
-import org.springframework.data.gemfire.function.annotation.RegionData;
-import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.Map;
+import org.springframework.data.gemfire.function.annotation.GemfireFunction;
+import org.springframework.data.gemfire.function.annotation.RegionData;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Patrick Johnson
+ */
@Component
public class OrderFunctions {
diff --git a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/ProductFunctions.java b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/ProductFunctions.java
index 8a9fda9e..77f155e6 100755
--- a/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/ProductFunctions.java
+++ b/geode/function-invocation/src/main/java/example/springdata/geode/client/function/server/ProductFunctions.java
@@ -13,21 +13,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.server;
import example.springdata.geode.client.function.Product;
-import org.springframework.data.gemfire.function.annotation.GemfireFunction;
-import org.springframework.data.gemfire.function.annotation.RegionData;
-import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.Map;
+import org.springframework.data.gemfire.function.annotation.GemfireFunction;
+import org.springframework.data.gemfire.function.annotation.RegionData;
+import org.springframework.stereotype.Component;
+
+/**
+ * @author Patrick Johnson
+ */
@Component
public class ProductFunctions {
- @GemfireFunction(id = "sumPricesForAllProductsFnc", HA = true, optimizeForWrite = false, hasResult = true)
+ @GemfireFunction(id = "sumPricesForAllProductsFnc", HA = true, hasResult = true)
public BigDecimal sumPricesForAllProductsFnc(@RegionData Map productData) {
return productData.values().stream().map(Product::getPrice).reduce(BigDecimal::add).get();
}
diff --git a/geode/function-invocation/src/test/java/example/springdata/geode/client/function/client/FunctionInvocationClientTests.java b/geode/function-invocation/src/test/java/example/springdata/geode/client/function/client/FunctionInvocationClientTests.java
index e2f60715..7462f928 100755
--- a/geode/function-invocation/src/test/java/example/springdata/geode/client/function/client/FunctionInvocationClientTests.java
+++ b/geode/function-invocation/src/test/java/example/springdata/geode/client/function/client/FunctionInvocationClientTests.java
@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.function.client;
+import static org.assertj.core.api.Assertions.*;
+
import example.springdata.geode.client.function.Address;
import example.springdata.geode.client.function.Customer;
import example.springdata.geode.client.function.EmailAddress;
@@ -23,19 +24,8 @@ import example.springdata.geode.client.function.LineItem;
import example.springdata.geode.client.function.Order;
import example.springdata.geode.client.function.Product;
import example.springdata.geode.client.function.server.FunctionServer;
-import org.apache.geode.cache.Region;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.junit4.SpringRunner;
+import lombok.extern.apachecommons.CommonsLog;
-import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
@@ -43,41 +33,43 @@ import java.util.Random;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
-import static org.assertj.core.api.Assertions.assertThat;
+import javax.annotation.Resource;
+import org.apache.geode.cache.Region;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author Patrick Johnson
+ */
@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = FunctionInvocationClientApplicationConfig.class)
-@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
+@SpringBootTest(classes = FunctionInvocationClientApplicationConfig.class)
+@CommonsLog
public class FunctionInvocationClientTests extends ForkingClientServerIntegrationTestsSupport {
- @Autowired
- private CustomerRepository customerRepository;
+ @Autowired private CustomerRepository customerRepository;
- @Autowired
- private OrderRepository orderRepository;
+ @Autowired private OrderRepository orderRepository;
- @Autowired
- private ProductRepository productRepository;
+ @Autowired private ProductRepository productRepository;
- @Autowired
- private CustomerFunctionExecutions customerFunctionExecutions;
+ @Autowired private CustomerFunctionExecutions customerFunctionExecutions;
- @Autowired
- private OrderFunctionExecutions orderFunctionExecutions;
+ @Autowired private OrderFunctionExecutions orderFunctionExecutions;
- @Autowired
- private ProductFunctionExecutions productFunctionExecutions;
+ @Autowired private ProductFunctionExecutions productFunctionExecutions;
- @Resource(name = "Customers")
- private Region customers;
+ @Resource(name = "Customers") private Region customers;
- @Resource(name = "Orders")
- private Region orders;
+ @Resource(name = "Orders") private Region orders;
- @Resource(name = "Products")
- private Region products;
-
- private Logger logger = LoggerFactory.getLogger(this.getClass());
+ @Resource(name = "Products") private Region products;
@BeforeClass
public static void setup() throws IOException {
@@ -90,56 +82,60 @@ public class FunctionInvocationClientTests extends ForkingClientServerIntegratio
List cust = customerFunctionExecutions.listAllCustomersForEmailAddress("2@2.com", "3@3.com").get(0);
assertThat(cust.size()).isEqualTo(2);
- logger.info("All customers for emailAddresses:3@3.com,2@2.com using function invocation: \n\t " + cust);
+ log.info("All customers for emailAddresses:3@3.com,2@2.com using function invocation: \n\t " + cust);
createProducts();
BigDecimal sum = productFunctionExecutions.sumPricesForAllProducts().get(0);
assertThat(sum).isEqualTo(BigDecimal.valueOf(1499.97));
- logger.info("Running function to sum up all product prices: \n\t" + sum);
+ log.info("Running function to sum up all product prices: \n\t" + sum);
createOrders();
sum = orderFunctionExecutions.sumPricesForAllProductsForOrder(1L).get(0);
assertThat(sum).isGreaterThanOrEqualTo(BigDecimal.valueOf(99.99));
- logger.info("Running function to sum up all order lineItems prices for order 1: \n\t" + sum);
+ log.info("Running function to sum up all order lineItems prices for order 1: \n\t" + sum);
Order order = orderRepository.findById(1L).get();
- logger.info("For order: \n\t " + order);
+ log.info("For order: \n\t " + order);
}
public void createCustomerData() {
- logger.info("Inserting 3 entries for keys: 1, 2, 3");
+ log.info("Inserting 3 entries for keys: 1, 2, 3");
+
customerRepository.save(new Customer(1L, new EmailAddress("2@2.com"), "John", "Smith"));
customerRepository.save(new Customer(2L, new EmailAddress("3@3.com"), "Frank", "Lamport"));
customerRepository.save(new Customer(3L, new EmailAddress("5@5.com"), "Jude", "Simmons"));
+
assertThat(customers.keySetOnServer().size()).isEqualTo(3);
}
public void createProducts() {
- productRepository.save(new Product(1L, "Apple iPod", new BigDecimal("99.99"),
- "An Apple portable music player"));
- productRepository.save(new Product(2L, "Apple iPad", new BigDecimal("499.99"),
- "An Apple tablet device"));
- Product macbook = new Product(3L, "Apple macBook", new BigDecimal("899.99"),
- "An Apple notebook computer");
+
+ productRepository.save(new Product(1L, "Apple iPod", new BigDecimal("99.99"), "An Apple portable music player"));
+ productRepository.save(new Product(2L, "Apple iPad", new BigDecimal("499.99"), "An Apple tablet device"));
+ Product macbook = new Product(3L, "Apple macBook", new BigDecimal("899.99"), "An Apple notebook computer");
macbook.addAttribute("warranty", "included");
+
productRepository.save(macbook);
+
assertThat(products.keySetOnServer().size()).isEqualTo(3);
}
public void createOrders() {
+
Random random = new Random();
Address address = new Address("it", "doesn't", "matter");
- LongStream.rangeClosed(1, 100).forEach((orderId) ->
- LongStream.rangeClosed(1, 3).forEach((customerId) -> {
- Order order = new Order(orderId, customerId, address);
- IntStream.rangeClosed(0, random.nextInt(3) + 1).forEach((lineItemCount) -> {
- int quantity = random.nextInt(3) + 1;
- long productId = random.nextInt(3) + 1;
- order.add(new LineItem(productRepository.findById(productId).get(), quantity));
- });
- orderRepository.save(order);
- }));
+
+ LongStream.rangeClosed(1, 100).forEach((orderId) -> LongStream.rangeClosed(1, 3).forEach((customerId) -> {
+ Order order = new Order(orderId, customerId, address);
+ IntStream.rangeClosed(0, random.nextInt(3) + 1).forEach((lineItemCount) -> {
+ int quantity = random.nextInt(3) + 1;
+ long productId = random.nextInt(3) + 1;
+ order.add(new LineItem(productRepository.findById(productId).get(), quantity));
+ });
+ orderRepository.save(order);
+ }));
+
assertThat(orders.keySetOnServer().size()).isEqualTo(100);
}
-}
\ No newline at end of file
+}
diff --git a/geode/pom.xml b/geode/pom.xml
index c780f93f..3d83358e 100755
--- a/geode/pom.xml
+++ b/geode/pom.xml
@@ -2,127 +2,78 @@
- 4.0.0
+ 4.0.0
- example.springdata.geode
- spring-data-geode-examples
- 1.0-SNAPSHOT
- https://github.com/spring-projects/spring-geode-examples
- pom
+ spring-data-geode-examples
+ pom
-
- events
- expiration-eviction
- function-invocation
- queries
- security
- storage
- transactions
- wan
-
+
+ org.springframework.data.examples
+ spring-data-examples
+ 2.0.0.BUILD-SNAPSHOT
+
-
- SpringSource
- http://springsource.org
-
+ Spring Data for Apache Geode - Examples
+ Sample projects for Spring Data for Apache Geode
+ https://projects.spring.io/spring-data-geode
-
-
- The Apache Software License, Version 2.0
- http://www.apache.org/licenses/LICENSE-2.0.txt
- repo
-
-
+
+ events
+ expiration-eviction
+ function-invocation
+ queries
+ security
+ storage
+ transactions
-
- org.springframework.data.build
- spring-data-parent
- 2.2.5.BUILD-SNAPSHOT
-
+
+
+
-
- 2.12.1
- 1.7.28
- 2.2.4.BUILD-SNAPSHOT
- 0.0.12.RELEASE
- Moore-RELEASE
-
+
+ 0.0.12.RELEASE
+
-
-
-
- org.springframework.data
- spring-data-releasetrain
- ${spring.data.releasetrain.version}
- pom
- import
-
-
-
+
+
+
+ org.awaitility
+ awaitility
+ 4.0.2
+
+
+ org.iq80.snappy
+ snappy
+ 0.4
+
+
+
-
-
- org.projectlombok
- lombok
- 1.18.12
- provided
-
-
- com.github.javafaker
- javafaker
- 1.0.1
-
-
- org.springframework.data
- spring-data-geode
- ${spring.boot.version}
-
-
- org.springframework.data
- spring-data-geode-test
- ${spring.test.data.geode.version}
- test
-
-
- org.springframework.boot
- spring-boot-starter
- ${spring.boot.version}
-
-
- org.springframework.boot
- spring-boot-starter-logging
-
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- ${spring.boot.version}
- test
-
-
- org.slf4j
- slf4j-api
- ${slf4j.log4j.version}
- compile
-
-
+
+
+ org.springframework.data
+ spring-data-geode
+
+
+ com.github.javafaker
+ javafaker
+ 1.0.1
+
+
+ org.springframework.data
+ spring-data-geode-test
+ ${spring.test.data.geode.version}
+ test
+
+
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
- ${spring.boot.version}
-
-
- maven-compiler-plugin
-
- 1.8
- 1.8
-
-
-
-
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
-
\ No newline at end of file
+
diff --git a/geode/queries/pom.xml b/geode/queries/pom.xml
index f4c942c3..753a969d 100755
--- a/geode/queries/pom.xml
+++ b/geode/queries/pom.xml
@@ -2,23 +2,22 @@
-
- example.springdata.geode
- spring-data-geode-examples
- 1.0-SNAPSHOT
-
- 4.0.0
+ 4.0.0
- example.springdata.geode.client
- queries
- 1.0-SNAPSHOT
-
-
- org.awaitility
- awaitility
- 3.1.6
- test
-
-
+
+ org.springframework.data.examples
+ spring-data-geode-examples
+ 2.0.0.BUILD-SNAPSHOT
+
-
\ No newline at end of file
+ queries
+
+
+
+ org.awaitility
+ awaitility
+ test
+
+
+
+
diff --git a/geode/queries/src/main/java/example/springdata/geode/client/queries/Customer.java b/geode/queries/src/main/java/example/springdata/geode/client/queries/Customer.java
index babebc0a..e252caa4 100755
--- a/geode/queries/src/main/java/example/springdata/geode/client/queries/Customer.java
+++ b/geode/queries/src/main/java/example/springdata/geode/client/queries/Customer.java
@@ -33,11 +33,10 @@ import java.io.Serializable;
@Data
@PartitionRegion(name = "Customers")
public class Customer implements Serializable {
+
@Id
private Long id;
-
private EmailAddress emailAddress;
-
private String firstName;
@LuceneIndexed(name = "lastName_lucene")
@@ -49,4 +48,4 @@ public class Customer implements Serializable {
this.firstName = firstName;
this.lastName = lastName;
}
-}
\ No newline at end of file
+}
diff --git a/geode/queries/src/main/java/example/springdata/geode/client/queries/EmailAddress.java b/geode/queries/src/main/java/example/springdata/geode/client/queries/EmailAddress.java
index 5e07ca50..b46aed3a 100755
--- a/geode/queries/src/main/java/example/springdata/geode/client/queries/EmailAddress.java
+++ b/geode/queries/src/main/java/example/springdata/geode/client/queries/EmailAddress.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.queries;
import lombok.Data;
@@ -28,10 +27,11 @@ import java.io.Serializable;
*/
@Data
public class EmailAddress implements Serializable {
+
private String value;
public EmailAddress(String value) {
this.value = value;
}
-}
\ No newline at end of file
+}
diff --git a/geode/queries/src/main/java/example/springdata/geode/client/queries/client/CustomerRepository.java b/geode/queries/src/main/java/example/springdata/geode/client/queries/client/CustomerRepository.java
index 81424cd7..297fbd3d 100755
--- a/geode/queries/src/main/java/example/springdata/geode/client/queries/client/CustomerRepository.java
+++ b/geode/queries/src/main/java/example/springdata/geode/client/queries/client/CustomerRepository.java
@@ -13,10 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.queries.client;
import example.springdata.geode.client.queries.Customer;
+
+import java.util.List;
+
import org.springframework.data.gemfire.mapping.annotation.ClientRegion;
import org.springframework.data.gemfire.repository.Query;
import org.springframework.data.gemfire.repository.query.annotation.Hint;
@@ -24,10 +26,12 @@ import org.springframework.data.gemfire.repository.query.annotation.Limit;
import org.springframework.data.gemfire.repository.query.annotation.Trace;
import org.springframework.data.repository.CrudRepository;
-import java.util.List;
-
+/**
+ * @author Patrick Johnson
+ */
@ClientRegion(name = "Customers")
public interface CustomerRepository extends CrudRepository {
+
@Trace
@Limit(100)
@Hint("emailAddressIndex")
diff --git a/geode/queries/src/main/java/example/springdata/geode/client/queries/client/QueryClientConfig.java b/geode/queries/src/main/java/example/springdata/geode/client/queries/client/QueryClientConfig.java
index 5b3de4c1..d616cb3b 100755
--- a/geode/queries/src/main/java/example/springdata/geode/client/queries/client/QueryClientConfig.java
+++ b/geode/queries/src/main/java/example/springdata/geode/client/queries/client/QueryClientConfig.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.queries.client;
import org.apache.geode.cache.GemFireCache;
@@ -28,9 +27,13 @@ import org.springframework.data.gemfire.config.annotation.EnableContinuousQuerie
import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories;
import org.springframework.data.gemfire.search.lucene.LuceneTemplate;
+/**
+ * @author Patrick Johnson
+ */
@Configuration
-@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class)
-@ClientCacheApplication(name = "CQClientCache", logLevel = "error", pingInterval = 5000L, readTimeout = 15000, subscriptionEnabled = true, readyForEvents = true)
+@EnableGemfireRepositories
+@ClientCacheApplication(name = "CQClientCache", logLevel = "error", pingInterval = 5000L, readTimeout = 15000,
+ subscriptionEnabled = true, readyForEvents = true)
@EnableContinuousQueries
@EnableClusterDefinedRegions(clientRegionShortcut = ClientRegionShortcut.PROXY)
public class QueryClientConfig {
@@ -45,4 +48,4 @@ public class QueryClientConfig {
LuceneTemplate createCustomerLuceneTemplate() {
return new LuceneTemplate("lastName_lucene", "/Customers");
}
-}
\ No newline at end of file
+}
diff --git a/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServer.java b/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServer.java
index cc95bce9..de36aeaf 100755
--- a/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServer.java
+++ b/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServer.java
@@ -13,17 +13,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.queries.server;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
-@SpringBootApplication(scanBasePackageClasses = QueryServerConfig.class)
+/**
+ * @author Patrick Johnson
+ */
+@SpringBootApplication
public class QueryServer {
public static void main(String[] args) {
new SpringApplicationBuilder(QueryServer.class).web(WebApplicationType.NONE).build().run(args);
}
-}
\ No newline at end of file
+}
diff --git a/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServerConfig.java b/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServerConfig.java
index 441e4760..aacf9f7a 100755
--- a/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServerConfig.java
+++ b/geode/queries/src/main/java/example/springdata/geode/client/queries/server/QueryServerConfig.java
@@ -13,11 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.queries.server;
import example.springdata.geode.client.queries.Customer;
import example.springdata.geode.client.queries.client.CustomerRepository;
+
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
@@ -27,6 +27,9 @@ import org.springframework.data.gemfire.config.annotation.EnableIndexing;
import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories;
import org.springframework.data.gemfire.search.lucene.LuceneTemplate;
+/**
+ * @author Patrick Johnson
+ */
@Configuration
@CacheServerApplication(logLevel = "error")
@EnableGemfireRepositories(basePackageClasses = CustomerRepository.class)
@@ -39,4 +42,4 @@ public class QueryServerConfig {
LuceneTemplate createCustomerLuceneTemplate() {
return new LuceneTemplate("lastName_lucene", "/Customers");
}
-}
\ No newline at end of file
+}
diff --git a/geode/queries/src/test/java/example/springdata/geode/client/queries/QueryTests.java b/geode/queries/src/test/java/example/springdata/geode/client/queries/QueryTests.java
index b026f237..9b56a66e 100755
--- a/geode/queries/src/test/java/example/springdata/geode/client/queries/QueryTests.java
+++ b/geode/queries/src/test/java/example/springdata/geode/client/queries/QueryTests.java
@@ -13,12 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.queries;
+import static org.assertj.core.api.Assertions.*;
+
import example.springdata.geode.client.queries.client.CustomerRepository;
import example.springdata.geode.client.queries.client.QueryClientConfig;
import example.springdata.geode.client.queries.server.QueryServer;
+import lombok.extern.apachecommons.CommonsLog;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.annotation.Resource;
+
import org.apache.geode.cache.Region;
import org.apache.geode.cache.lucene.LuceneResultStruct;
import org.apache.geode.cache.query.CqEvent;
@@ -27,8 +37,7 @@ import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.gemfire.GemfireTemplate;
@@ -36,41 +45,28 @@ import org.springframework.data.gemfire.listener.ContinuousQueryListenerContaine
import org.springframework.data.gemfire.listener.annotation.ContinuousQuery;
import org.springframework.data.gemfire.search.lucene.LuceneTemplate;
import org.springframework.data.gemfire.tests.integration.ForkingClientServerIntegrationTestsSupport;
-import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
-import javax.annotation.Resource;
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
+/**
+ * @author Patrick Johnson
+ */
@RunWith(SpringRunner.class)
-@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = QueryClientConfig.class)
-@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
+@SpringBootTest(classes = QueryClientConfig.class)
+@CommonsLog
public class QueryTests extends ForkingClientServerIntegrationTestsSupport {
- @Autowired
- private ContinuousQueryListenerContainer container;
+ @Autowired private ContinuousQueryListenerContainer container;
- @Autowired
- private CustomerRepository customerRepository;
+ @Autowired private CustomerRepository customerRepository;
- @Autowired
- private GemfireTemplate customerTemplate;
+ @Autowired private GemfireTemplate customerTemplate;
- @Resource(name = "Customers")
- private Region customers;
+ @Resource(name = "Customers") private Region customers;
- @Autowired
- private LuceneTemplate luceneTemplate;
+ @Autowired private LuceneTemplate luceneTemplate;
private AtomicInteger counter = new AtomicInteger(0);
- private Logger logger = LoggerFactory.getLogger(this.getClass());
-
@BeforeClass
public static void setup() throws IOException {
startGemFireServer(QueryServer.class);
@@ -88,14 +84,14 @@ public class QueryTests extends ForkingClientServerIntegrationTestsSupport {
List> lastName = luceneTemplate.query("D*", "lastName", 10);
assertThat(lastName.size()).isEqualTo(3);
- logger.info("Customers with last names beginning with 'D':");
- lastName.forEach(result -> logger.info(result.getValue().toString()));
+ log.info("Customers with last names beginning with 'D':");
+ lastName.forEach(result -> log.info(result.getValue().toString()));
}
@Test
public void oqlQueriesConfiguredCorrectly() {
- logger.info("Inserting 3 entries for keys: 1, 2, 3");
+ log.info("Inserting 3 entries for keys: 1, 2, 3");
Customer john = new Customer(1L, new EmailAddress("2@2.com"), "John", "Smith");
Customer frank = new Customer(2L, new EmailAddress("3@3.com"), "Frank", "Lamport");
Customer jude = new Customer(3L, new EmailAddress("5@5.com"), "Jude", "Simmons");
@@ -106,11 +102,11 @@ public class QueryTests extends ForkingClientServerIntegrationTestsSupport {
Customer customer = customerRepository.findById(2L).get();
assertThat(customer).isEqualTo(frank);
- logger.info("Find customer with key=2 using GemFireRepository: " + customer);
+ log.info("Find customer with key=2 using GemFireRepository: " + customer);
List customerList = customerTemplate.find("select * from /Customers where id=$1", 2L).asList();
assertThat(customerList.size()).isEqualTo(1);
assertThat(customerList.contains(frank)).isTrue();
- logger.info("Find customer with key=2 using GemFireTemplate: " + customerList);
+ log.info("Find customer with key=2 using GemFireTemplate: " + customerList);
customer = new Customer(1L, new EmailAddress("3@3.com"), "Jude", "Smith");
customerRepository.save(customer);
@@ -120,25 +116,33 @@ public class QueryTests extends ForkingClientServerIntegrationTestsSupport {
assertThat(customerList.size()).isEqualTo(2);
assertThat(customerList.contains(frank)).isTrue();
assertThat(customerList.contains(customer)).isTrue();
- logger.info("Find customers with emailAddress=3@3.com: " + customerList);
+ log.info("Find customers with emailAddress=3@3.com: " + customerList);
customerList = customerRepository.findByFirstNameUsingIndex("Frank");
assertThat(customerList.get(0)).isEqualTo(frank);
- logger.info("Find customers with firstName=Frank: " + customerList);
+
+ log.info("Find customers with firstName=Frank: " + customerList);
+
customerList = customerRepository.findByFirstNameUsingIndex("Jude");
+
assertThat(customerList.size()).isEqualTo(2);
assertThat(customerList.contains(jude)).isTrue();
assertThat(customerList.contains(customer)).isTrue();
- logger.info("Find customers with firstName=Jude: " + customerList);
+
+ log.info("Find customers with firstName=Jude: " + customerList);
}
@Test
public void continuousQueryWorkingCorrectly() {
+
assertThat(this.customers).isEmpty();
- logger.info("Inserting 3 entries for keys: 1, 2, 3");
+
+ log.info("Inserting 3 entries for keys: 1, 2, 3");
+
customerRepository.save(new Customer(1L, new EmailAddress("2@2.com"), "John", "Smith"));
customerRepository.save(new Customer(2L, new EmailAddress("3@3.com"), "Frank", "Lamport"));
customerRepository.save(new Customer(3L, new EmailAddress("5@5.com"), "Jude", "Simmons"));
+
assertThat(customers.keySetOnServer().size()).isEqualTo(3);
Awaitility.await().atMost(30, TimeUnit.SECONDS).until(() -> this.counter.get() == 3);
@@ -146,7 +150,7 @@ public class QueryTests extends ForkingClientServerIntegrationTestsSupport {
@ContinuousQuery(name = "CustomerCQ", query = "SELECT * FROM /Customers")
public void handleEvent(CqEvent event) {
- logger.info("Received message for CQ 'CustomerCQ'" + event);
+ log.info("Received message for CQ 'CustomerCQ'" + event);
counter.incrementAndGet();
}
@@ -155,4 +159,4 @@ public class QueryTests extends ForkingClientServerIntegrationTestsSupport {
customerRepository.deleteAll(customerRepository.findAll());
container.getQueryService().closeCqs();
}
-}
\ No newline at end of file
+}
diff --git a/geode/security/pom.xml b/geode/security/pom.xml
index c5663e94..f2f7b51b 100755
--- a/geode/security/pom.xml
+++ b/geode/security/pom.xml
@@ -2,41 +2,33 @@
+ 4.0.0
+
- example.springdata.geode
+ org.springframework.data.examplesspring-data-geode-examples
- 1.0-SNAPSHOT
+ 2.0.0.BUILD-SNAPSHOT
- 4.0.0securityorg.springframeworkspring-jdbc
- 5.2.3.RELEASEorg.springframework.dataspring-data-jpa
- 2.2.4.RELEASE
-
-
- org.codeprimate
- cp-elements
- 1.0.0.M5org.hsqldbhsqldb
- 2.4.1javax.persistencejavax.persistence-api
- 2.2
-
\ No newline at end of file
+
diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/Constants.java b/geode/security/src/main/java/example/springdata/geode/client/security/Constants.java
index de045712..c8511f93 100755
--- a/geode/security/src/main/java/example/springdata/geode/client/security/Constants.java
+++ b/geode/security/src/main/java/example/springdata/geode/client/security/Constants.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.security;
/**
diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/Customer.java b/geode/security/src/main/java/example/springdata/geode/client/security/Customer.java
index 39dd25e2..aed09eea 100755
--- a/geode/security/src/main/java/example/springdata/geode/client/security/Customer.java
+++ b/geode/security/src/main/java/example/springdata/geode/client/security/Customer.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.security;
import lombok.Data;
@@ -44,4 +43,4 @@ public class Customer implements Serializable {
this.firstName = firstName;
this.lastName = lastName;
}
-}
\ No newline at end of file
+}
diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/EmailAddress.java b/geode/security/src/main/java/example/springdata/geode/client/security/EmailAddress.java
index bc222121..85f60acd 100755
--- a/geode/security/src/main/java/example/springdata/geode/client/security/EmailAddress.java
+++ b/geode/security/src/main/java/example/springdata/geode/client/security/EmailAddress.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.security;
import lombok.Data;
@@ -34,4 +33,4 @@ public class EmailAddress implements Serializable {
this.value = value;
}
-}
\ No newline at end of file
+}
diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/Role.java b/geode/security/src/main/java/example/springdata/geode/client/security/Role.java
index dd9fc6be..a832c5da 100755
--- a/geode/security/src/main/java/example/springdata/geode/client/security/Role.java
+++ b/geode/security/src/main/java/example/springdata/geode/client/security/Role.java
@@ -13,12 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.security;
import lombok.Data;
-import org.apache.geode.security.ResourcePermission;
-import org.cp.elements.lang.Identifiable;
import java.io.Serializable;
import java.util.Arrays;
@@ -26,6 +23,8 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
+import org.apache.geode.security.ResourcePermission;
+
/**
* The [Role] class is an Abstract Data Type (ADT) modeling a role of a user (e.g. Admin).
*
@@ -34,11 +33,10 @@ import java.util.Iterator;
* @see Comparable
* @see Iterable
* @see ResourcePermission
- * @see org.cp.elements.lang.Identifiable
* @since 1.0.0
*/
@Data
-public class Role implements Comparable, Identifiable, Iterable, Serializable {
+public class Role implements Comparable, Iterable, Serializable {
private String name;
private HashSet permissions = new HashSet<>();
@@ -47,12 +45,10 @@ public class Role implements Comparable, Identifiable, Iterable, Identifiable, Iterable, Cloneable, Principal, Serializable, Iterable, Identifiable {
+public class User implements Comparable, Cloneable, Principal, Serializable, Iterable {
private String name;
private List roles;
@@ -42,15 +44,13 @@ public class User implements Comparable, Cloneable, Principal, Serializabl
}
public User(String name) {
- this(name, new ArrayList());
+ this(name, new ArrayList<>());
}
- @Override
public void setId(String id) {
throw new UnsupportedOperationException("Operation Not Supported");
}
- @Override
public String getId() {
return name;
}
@@ -80,8 +80,7 @@ public class User implements Comparable, Cloneable, Principal, Serializabl
* Determines whether this [User] has been granted (assigned) the given [permission][ResourcePermission].
*
* @param permission [ResourcePermission] to evalute.
- * @return a boolean value indicating whether this [User] has been granted (assigned)
- * the given [ResourcePermission].
+ * @return a boolean value indicating whether this [User] has been granted (assigned) the given [ResourcePermission].
* @see ResourcePermission
*/
public boolean hasPermission(ResourcePermission permission) {
diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/client/CustomerRepository.java b/geode/security/src/main/java/example/springdata/geode/client/security/client/CustomerRepository.java
index dacd8e9d..3d782b66 100755
--- a/geode/security/src/main/java/example/springdata/geode/client/security/client/CustomerRepository.java
+++ b/geode/security/src/main/java/example/springdata/geode/client/security/client/CustomerRepository.java
@@ -13,14 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.security.client;
import example.springdata.geode.client.security.Customer;
-import org.springframework.data.repository.CrudRepository;
import java.util.List;
+import org.springframework.data.repository.CrudRepository;
+
+/**
+ * @author Patrick Johnson
+ */
public interface CustomerRepository extends CrudRepository {
+
+ @Override
List findAll();
+
}
diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/client/SecurityEnabledClientConfiguration.java b/geode/security/src/main/java/example/springdata/geode/client/security/client/SecurityEnabledClientConfiguration.java
index 88754f38..5c934592 100755
--- a/geode/security/src/main/java/example/springdata/geode/client/security/client/SecurityEnabledClientConfiguration.java
+++ b/geode/security/src/main/java/example/springdata/geode/client/security/client/SecurityEnabledClientConfiguration.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.security.client;
import example.springdata.geode.client.security.Customer;
@@ -30,4 +29,4 @@ import org.springframework.data.gemfire.repository.config.EnableGemfireRepositor
@ClientCacheApplication(name = "SecurityClient", logLevel = "error", pingInterval = 5000L, readTimeout = 15000, retryAttempts = 1)
@EnableEntityDefinedRegions(basePackageClasses = Customer.class, clientRegionShortcut = ClientRegionShortcut.CACHING_PROXY)
public class SecurityEnabledClientConfiguration {
-}
\ No newline at end of file
+}
diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/ApacheShiroIniConfiguration.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/ApacheShiroIniConfiguration.java
index fd9f187d..53f54611 100644
--- a/geode/security/src/main/java/example/springdata/geode/client/security/server/ApacheShiroIniConfiguration.java
+++ b/geode/security/src/main/java/example/springdata/geode/client/security/server/ApacheShiroIniConfiguration.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2020 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package example.springdata.geode.client.security.server;
import org.springframework.context.annotation.Configuration;
@@ -7,5 +22,4 @@ import org.springframework.data.gemfire.config.annotation.EnableSecurity;
@Configuration
@EnableSecurity(shiroIniResourcePath = "shiro.ini")
@Profile("shiro-ini-configuration")
-public class ApacheShiroIniConfiguration {
-}
+public class ApacheShiroIniConfiguration {}
diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/CachingSecurityRepository.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/CachingSecurityRepository.java
index 94ac8202..cdf6be29 100755
--- a/geode/security/src/main/java/example/springdata/geode/client/security/server/CachingSecurityRepository.java
+++ b/geode/security/src/main/java/example/springdata/geode/client/security/server/CachingSecurityRepository.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.security.server;
import example.springdata.geode.client.security.User;
@@ -31,6 +30,7 @@ import java.util.Map;
* @since 1.0.0
*/
public abstract class CachingSecurityRepository implements SecurityRepository {
+
private Map users = new HashMap<>();
@Override
diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/GeodeIntegratedSecurityProxyConfiguration.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/GeodeIntegratedSecurityProxyConfiguration.java
index 05faf3b7..633fe65d 100644
--- a/geode/security/src/main/java/example/springdata/geode/client/security/server/GeodeIntegratedSecurityProxyConfiguration.java
+++ b/geode/security/src/main/java/example/springdata/geode/client/security/server/GeodeIntegratedSecurityProxyConfiguration.java
@@ -1,13 +1,28 @@
+/*
+ * Copyright 2020 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package example.springdata.geode.client.security.server;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.data.gemfire.config.annotation.EnableSecurity;
-
+/**
+ * @author Patrick Johnson
+ */
@Configuration
@EnableSecurity(securityManagerClassName = "example.springdata.geode.client.security.server.SecurityManagerProxy")
-@Profile({"default", "geode-security-manager-proxy-configuration"})
-public class GeodeIntegratedSecurityProxyConfiguration {
-
-}
+@Profile({ "default", "geode-security-manager-proxy-configuration" })
+public class GeodeIntegratedSecurityProxyConfiguration {}
diff --git a/geode/security/src/main/java/example/springdata/geode/client/security/server/JdbcSecurityRepository.java b/geode/security/src/main/java/example/springdata/geode/client/security/server/JdbcSecurityRepository.java
index b8608524..599abda6 100644
--- a/geode/security/src/main/java/example/springdata/geode/client/security/server/JdbcSecurityRepository.java
+++ b/geode/security/src/main/java/example/springdata/geode/client/security/server/JdbcSecurityRepository.java
@@ -13,42 +13,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package example.springdata.geode.client.security.server;
import example.springdata.geode.client.security.Role;
import example.springdata.geode.client.security.User;
-import org.apache.geode.security.ResourcePermission;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.RowMapper;
-import org.springframework.stereotype.Repository;
+import lombok.extern.apachecommons.CommonsLog;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
-@Repository
-public class JdbcSecurityRepository extends CachingSecurityRepository implements InitializingBean {
+import org.apache.geode.security.ResourcePermission;
- private Logger logger = LoggerFactory.getLogger(this.getClass());
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author Patrick Johnson
+ */
+@Repository
+@CommonsLog
+public class JdbcSecurityRepository extends CachingSecurityRepository implements InitializingBean {
private final JdbcTemplate jdbcTemplate;
private static final String ROLES_QUERY = "SELECT name FROM geode_security.roles";
private static final String ROLE_PERMISSIONS_QUERY = ""
+ " SELECT rolePerms.resource, rolePerms.operation, rolePerms.region_name, rolePerms.key_name"
+ " FROM geode_security.roles_permissions rolePerms"
- + " INNER JOIN geode_security.roles roles ON roles.id = rolePerms.role_id "
- + " WHERE roles.name = ?";
+ + " INNER JOIN geode_security.roles roles ON roles.id = rolePerms.role_id " + " WHERE roles.name = ?";
private static final String USERS_QUERY = "SELECT name, credentials FROM geode_security.users";
- private static final String USER_ROLES_QUERY = ""
- + " SELECT roles.name"
- + " FROM geode_security.roles roles"
+ private static final String USER_ROLES_QUERY = "" + " SELECT roles.name" + " FROM geode_security.roles roles"
+ " INNER JOIN geode_security.users_roles userRoles ON roles.id = userRoles.role_id"
- + " INNER JOIN geode_security.users users ON userRoles.user_id = users.id"
- + " WHERE users.name = ?";
+ + " INNER JOIN geode_security.users users ON userRoles.user_id = users.id" + " WHERE users.name = ?";
public JdbcSecurityRepository(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
@@ -61,15 +59,14 @@ public class JdbcSecurityRepository extends CachingSecurityRepository implements
roles.forEach((role) -> {
this.jdbcTemplate.query(ROLE_PERMISSIONS_QUERY, Collections.singleton(role.getName()).toArray(),
- (RowMapper