diff --git a/spring-data-geode/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java b/spring-data-geode/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java
index a1594a03..f8d19071 100644
--- a/spring-data-geode/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java
+++ b/spring-data-geode/src/main/java/org/springframework/data/gemfire/client/ClientCacheFactoryBean.java
@@ -685,7 +685,7 @@ public class ClientCacheFactoryBean extends CacheFactoryBean implements Applicat
/**
* Sets (configures) the {@link PoolResolver} used by this {@link ClientCache} to resolve {@link Pool} objects.
- *
+ *
* The {@link Pool} objects may be managed or un-managed depending on the {@link PoolResolver} implementation.
*
* @param poolResolver {@link PoolResolver} used to resolve the configured {@link Pool}.
diff --git a/spring-data-geode/src/main/java/org/springframework/data/gemfire/client/GemfireDataSourcePostProcessor.java b/spring-data-geode/src/main/java/org/springframework/data/gemfire/client/GemfireDataSourcePostProcessor.java
index 70295956..213486ef 100644
--- a/spring-data-geode/src/main/java/org/springframework/data/gemfire/client/GemfireDataSourcePostProcessor.java
+++ b/spring-data-geode/src/main/java/org/springframework/data/gemfire/client/GemfireDataSourcePostProcessor.java
@@ -25,39 +25,33 @@ import org.apache.geode.cache.execute.Function;
import org.apache.geode.management.internal.cli.domain.RegionInformation;
import org.apache.geode.management.internal.cli.functions.GetRegionsFunction;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.springframework.beans.BeansException;
import org.springframework.beans.TypeMismatchException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
-import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.data.gemfire.client.function.ListRegionsOnServerFunction;
import org.springframework.data.gemfire.function.execution.GemfireOnServersFunctionTemplate;
+import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
- * A Spring {@link BeanFactoryPostProcessor} used to register a Client Region beans for each Region accessible to
- * an Apache Geode or Pivotal GemFire DataSource. If the Region is already defined, the bean definition
- * will not be overridden.
+ * A Spring {@link BeanPostProcessor} used to register a {@link ClientCache} {@link Region} beans
+ * for each {@link Region} accessible to an Apache Geode DataSource. If the {@link Region} is already
+ * defined as a bean, then the existing bean definition will not be overridden.
*
* @author David Turanski
* @author John Blum
* @see org.apache.geode.cache.Region
* @see org.apache.geode.cache.client.ClientCache
* @see org.apache.geode.cache.client.ClientRegionFactory
- * @see org.apache.geode.cache.client.ClientRegionShortcut
- * @see org.apache.geode.cache.execute.Function
* @see org.apache.geode.management.internal.cli.functions.GetRegionsFunction
- * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor
- * @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory
* @see org.springframework.data.gemfire.client.function.ListRegionsOnServerFunction
- * @see org.springframework.data.gemfire.function.execution.GemfireOnServersFunctionTemplate
- * @see ListRegionsOnServerFunction
* @since 1.2.0
*/
public class GemfireDataSourcePostProcessor implements BeanFactoryAware, BeanPostProcessor {
@@ -79,7 +73,7 @@ public class GemfireDataSourcePostProcessor implements BeanFactoryAware, BeanPos
* @see org.springframework.beans.factory.BeanFactory
*/
@Override
- public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+ public void setBeanFactory(@NonNull BeanFactory beanFactory) throws BeansException {
if (beanFactory instanceof ConfigurableBeanFactory) {
this.beanFactory = (ConfigurableBeanFactory) beanFactory;
@@ -106,7 +100,7 @@ public class GemfireDataSourcePostProcessor implements BeanFactoryAware, BeanPos
* used by the client {@link Region}.
* @see org.apache.geode.cache.client.ClientRegionShortcut
*/
- public void setClientRegionShortcut(ClientRegionShortcut clientRegionShortcut) {
+ public void setClientRegionShortcut(@Nullable ClientRegionShortcut clientRegionShortcut) {
this.clientRegionShortcut = clientRegionShortcut;
}
@@ -123,13 +117,15 @@ public class GemfireDataSourcePostProcessor implements BeanFactoryAware, BeanPos
}
/**
- * Resolves the {@link ClientRegionShortcut} used to configure and create client {@link Region Regions}.
+ * Resolves the {@link ClientRegionShortcut} used to create and configure client {@link Region Regions}.
+ *
+ * Defaults to {@link ClientRegionShortcut#PROXY}.
*
* @return the resolved {@link ClientRegionShortcut}.
* @see org.apache.geode.cache.client.ClientRegionShortcut
* @see #getClientRegionShortcut()
*/
- protected ClientRegionShortcut resolveClientRegionShortcut() {
+ protected @NonNull ClientRegionShortcut resolveClientRegionShortcut() {
return getClientRegionShortcut().orElse(DEFAULT_CLIENT_REGION_SHORTCUT);
}
@@ -157,7 +153,7 @@ public class GemfireDataSourcePostProcessor implements BeanFactoryAware, BeanPos
}
- // TODO: remove this logic and delegate to o.s.d.g.config.remote.GemfireAdminOperations
+ // TODO: Remove this logic and delegate to o.s.d.g.config.remote.GemfireAdminOperations
Iterable regionNames(ClientCache clientCache) {
try {
@@ -191,6 +187,7 @@ public class GemfireDataSourcePostProcessor implements BeanFactoryAware, BeanPos
}
}
+ @SuppressWarnings("rawtypes")
T execute(ClientCache clientCache, Function gemfireFunction, Object... arguments) {
return new GemfireOnServersFunctionTemplate(clientCache).executeAndExtract(gemfireFunction, arguments);
}
@@ -255,17 +252,13 @@ public class GemfireDataSourcePostProcessor implements BeanFactoryAware, BeanPos
}
}
- public GemfireDataSourcePostProcessor using(ClientRegionShortcut clientRegionShortcut) {
-
+ public @NonNull GemfireDataSourcePostProcessor using(ClientRegionShortcut clientRegionShortcut) {
setClientRegionShortcut(clientRegionShortcut);
-
return this;
}
- public GemfireDataSourcePostProcessor using(BeanFactory beanFactory) {
-
+ public @NonNull GemfireDataSourcePostProcessor using(@NonNull BeanFactory beanFactory) {
setBeanFactory(beanFactory);
-
return this;
}
}
diff --git a/spring-data-geode/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java b/spring-data-geode/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java
index 151e5879..58b6d8fa 100644
--- a/spring-data-geode/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java
+++ b/spring-data-geode/src/main/java/org/springframework/data/gemfire/client/PoolFactoryBean.java
@@ -53,10 +53,10 @@ import org.springframework.util.StringUtils;
/**
* Spring {@link FactoryBean} used to construct, configure and initialize a {@link Pool}.
- *
+ *
* If a new {@link Pool} is created, its lifecycle is bound to that of this declaring {@link FactoryBean}
* and indirectly, the Spring container.
- *
+ *
* If a {@link Pool} having the configured {@link String name} already exists, then the existing {@link Pool}
* will be returned as is without any modifications and its lifecycle will be unaffected by this {@link FactoryBean}.
*
diff --git a/spring-data-geode/src/main/java/org/springframework/data/gemfire/config/admin/GemfireAdminOperations.java b/spring-data-geode/src/main/java/org/springframework/data/gemfire/config/admin/GemfireAdminOperations.java
index 8e07638d..0b950c29 100644
--- a/spring-data-geode/src/main/java/org/springframework/data/gemfire/config/admin/GemfireAdminOperations.java
+++ b/spring-data-geode/src/main/java/org/springframework/data/gemfire/config/admin/GemfireAdminOperations.java
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.springframework.data.gemfire.config.admin;
import static java.util.Arrays.stream;
@@ -30,8 +29,7 @@ import org.springframework.data.gemfire.config.schema.definitions.IndexDefinitio
import org.springframework.data.gemfire.config.schema.definitions.RegionDefinition;
/**
- * The {@link GemfireAdminOperations} interface defines a set of operations to define schema objects in a remote
- * Apache Geode or Pivotal GemFire cluster.
+ * Interface defining a set of operations for defining schema objects in a remote Apache Geode cluster.
*
* @author John Blum
* @see org.apache.geode.cache.DiskStore
diff --git a/spring-data-geode/src/main/java/org/springframework/data/gemfire/repository/query/QueryPostProcessor.java b/spring-data-geode/src/main/java/org/springframework/data/gemfire/repository/query/QueryPostProcessor.java
index b95e91b2..cbdbe3ec 100644
--- a/spring-data-geode/src/main/java/org/springframework/data/gemfire/repository/query/QueryPostProcessor.java
+++ b/spring-data-geode/src/main/java/org/springframework/data/gemfire/repository/query/QueryPostProcessor.java
@@ -26,22 +26,23 @@ import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
/**
- * The {@link QueryPostProcessor} interface defines a contract for implementations to post process
- * a given {@link QUERY query} and possibly return a new or modified version of the same {@link QUERY query}.
- *
- * {@link QueryPostProcessor QueryPostProcessors} are useful for handling and processing {@link QUERY queries}
- * derived from {@link Repository} {@link QueryMethod QueryMethods}, and give a developer the opportunity,
- * via the callback, to further process the generated {@link QUERY query}.
- *
+ * Interface defining contract for implementations to post process a given {@link QUERY query} and possibly return
+ * a new or modified version of the same {@link QUERY query}.
+ *
+ * {@link QueryPostProcessor QueryPostProcessors} are useful for processing {@link QUERY queries} derived from
+ * {@link Repository} {@link QueryMethod QueryMethods}, and give developers an opportunity, through this callback,
+ * to further process the generated {@link QUERY query}.
+ *
* {@link QueryPostProcessor QueryPostProcessors} can be used on both {@literal derived} {@link QUERY queries}
- * and {@literal manual} {@link QUERY queries}. {@literal Manual} {@link QUERY queries} are defined as
- * {@link QUERY queries} specified using SDG's {@link Query @Query} annotation or by defining a {@literal named}
- * {@link QUERY query} in a module-specific {@link Properties} files
- * (e.g. {@literal META-INF/gemfire-named-queries.properties}).
+ * as well as {@literal manual} {@link QUERY queries}.
+ *
+ * {@literal Manual} {@link QUERY queries} are defined as {@link QUERY queries} specified using the {@link Query @Query}
+ * annotation or by defining a {@literal named} {@link QUERY query} in a module-specific {@link Properties} files,
+ * for example: {@literal META-INF/gemfire-named-queries.properties}).
*
* @author John Blum
* @param {@link Class type} identifying the {@link Repository Repositories} to match on during registration.
- * @param {@link Class type} of the query to process.
+ * @param {@link Class type} of the {@literal query} to process.
* @see java.lang.FunctionalInterface
* @see org.springframework.core.Ordered
* @see org.springframework.data.gemfire.repository.Query
@@ -59,7 +60,7 @@ public interface QueryPostProcessor extends Ordered
/**
* Defines the {@link Integer order} of this {@link QueryPostProcessor} relative to
* other {@link QueryPostProcessor QueryPostProcessors} in a sort.
- *
+ *
* Defaults to the {@link Ordered#LOWEST_PRECEDENCE}.
*
* @return an {@link Integer} value specifying the order of this {@link QueryPostProcessor} relative to
@@ -74,7 +75,7 @@ public interface QueryPostProcessor extends Ordered
/**
* Callback method invoked by the Spring Data (SD) {@link Repository} framework to allow the user to process
* the given {@link QUERY query} and (possibly) return a new or modified version of the {@link QUERY query}.
- *
+ *
* This callback is invoked for {@literal queries} generated from a SD {@link Repository} {@link QueryMethod}
* signature as well as {@literal queries} specified and defined in {@link NamedQueries},
* or even using SDG's {@link Query @Query} annotation.
@@ -91,7 +92,7 @@ public interface QueryPostProcessor extends Ordered
/**
* Callback method invoked by the Spring Data (SD) {@link Repository} framework to allow the user to process
* the given {@link QUERY query} and (possibly) return a new or modified version of the {@link QUERY query}.
- *
+ *
* This callback is invoked for {@literal queries} generated from a SD {@link Repository} {@link QueryMethod}
* signature as well as {@literal queries} specified and defined in {@link NamedQueries},
* or even using SDG's {@link Query @Query} annotation.
@@ -102,12 +103,12 @@ public interface QueryPostProcessor extends Ordered
* @see org.springframework.data.repository.query.QueryMethod
* @see #postProcess(QueryMethod, Object)
*/
- QUERY postProcess(@NonNull QueryMethod queryMethod, QUERY query, Object... arguments);
+ QUERY postProcess(QueryMethod queryMethod, QUERY query, Object... arguments);
/**
* Builder method used to compose this {@link QueryPostProcessor QueryPostProcessor}
* with the given {@link QueryPostProcessor}.
- *
+ *
* This {@link QueryPostProcessor} will process the query before the given {@link QueryPostProcessor}
* in the processing chain.
*
@@ -118,6 +119,7 @@ public interface QueryPostProcessor extends Ordered
* @see #processAfter(QueryPostProcessor)
*/
default @NonNull QueryPostProcessor processBefore(@Nullable QueryPostProcessor queryPostProcessor) {
+
return queryPostProcessor == null ? this : (queryMethod, query, arguments) ->
queryPostProcessor.postProcess(queryMethod, this.postProcess(queryMethod, query, arguments), arguments);
}
@@ -125,7 +127,7 @@ public interface QueryPostProcessor extends Ordered
/**
* Builder method used to compose this {@link QueryPostProcessor QueryPostProcessors}
* with the given {@link QueryPostProcessor}.
- *
+ *
* This {@link QueryPostProcessor} will process the query after the given {@link QueryPostProcessor}
* in the processing chain.
*
@@ -136,6 +138,7 @@ public interface QueryPostProcessor extends Ordered
* @see #processBefore(QueryPostProcessor)
*/
default @NonNull QueryPostProcessor processAfter(@Nullable QueryPostProcessor queryPostProcessor) {
+
return queryPostProcessor == null ? this : (queryMethod, query, arguments) ->
this.postProcess(queryMethod, queryPostProcessor.postProcess(queryMethod, query, arguments), arguments);
}
diff --git a/spring-data-geode/src/main/java/org/springframework/data/gemfire/search/lucene/LuceneIndexFactoryBean.java b/spring-data-geode/src/main/java/org/springframework/data/gemfire/search/lucene/LuceneIndexFactoryBean.java
index 2a55b601..37f732a6 100644
--- a/spring-data-geode/src/main/java/org/springframework/data/gemfire/search/lucene/LuceneIndexFactoryBean.java
+++ b/spring-data-geode/src/main/java/org/springframework/data/gemfire/search/lucene/LuceneIndexFactoryBean.java
@@ -16,13 +16,11 @@
*/
package org.springframework.data.gemfire.search.lucene;
-import static java.util.stream.StreamSupport.stream;
-import static org.springframework.data.gemfire.util.ArrayUtils.nullSafeArray;
+import static org.springframework.data.gemfire.util.CollectionUtils.isEmpty;
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeCollection;
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeIterable;
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeList;
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeMap;
-import static org.springframework.util.CollectionUtils.isEmpty;
import java.util.Arrays;
import java.util.Collections;
@@ -30,6 +28,7 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Supplier;
+import java.util.stream.StreamSupport;
import org.apache.geode.cache.GemFireCache;
import org.apache.geode.cache.Region;
@@ -39,18 +38,19 @@ import org.apache.geode.cache.lucene.LuceneSerializer;
import org.apache.geode.cache.lucene.LuceneService;
import org.apache.geode.cache.lucene.LuceneServiceProvider;
-import org.apache.lucene.analysis.Analyzer;
-
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.gemfire.config.annotation.IndexConfigurer;
import org.springframework.data.gemfire.support.AbstractFactoryBeanSupport;
+import org.springframework.data.gemfire.util.ArrayUtils;
import org.springframework.data.gemfire.util.CacheUtils;
import org.springframework.data.gemfire.util.SpringExtensions;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
+import org.apache.lucene.analysis.Analyzer;
+
/**
* Spring {@link FactoryBean} used to construct, configure and initialize {@link LuceneIndex Lucene Indexes}
* on application domain object fields.
@@ -82,11 +82,11 @@ public class LuceneIndexFactoryBean extends AbstractFactoryBeanSupport indexConfigurers = Collections.emptyList();
- private IndexConfigurer compositeIndexConfigurer = new IndexConfigurer() {
+ private final IndexConfigurer compositeIndexConfigurer = new IndexConfigurer() {
@Override
public void configure(String beanName, LuceneIndexFactoryBean bean) {
- nullSafeCollection(indexConfigurers)
+ nullSafeCollection(LuceneIndexFactoryBean.this.indexConfigurers)
.forEach(indexConfigurer -> indexConfigurer.configure(beanName, bean));
}
};
@@ -143,7 +143,8 @@ public class LuceneIndexFactoryBean extends AbstractFactoryBeanSupport indexConfigurers) {
- stream(nullSafeIterable(indexConfigurers).spliterator(), false)
+ StreamSupport.stream(nullSafeIterable(indexConfigurers).spliterator(), false)
.forEach(indexConfigurer -> indexConfigurer.configure(indexName, this));
}
@@ -386,6 +387,7 @@ public class LuceneIndexFactoryBean extends AbstractFactoryBeanSupport resolveRegion() {
return Optional.ofNullable(getRegion()).orElseGet(() -> {
@@ -515,7 +517,7 @@ public class LuceneIndexFactoryBean extends AbstractFactoryBeanSupport
* This method is generally used for testing purposes only.
*
* @param luceneIndex {@link LuceneIndex} created by this {@link FactoryBean}.
@@ -608,9 +610,7 @@ public class LuceneIndexFactoryBean extends AbstractFactoryBeanSupport getObjectType() {
diff --git a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemfireDataSourcePostProcessorTest.java b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemfireDataSourcePostProcessorUnitTests.java
similarity index 84%
rename from spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemfireDataSourcePostProcessorTest.java
rename to spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemfireDataSourcePostProcessorUnitTests.java
index dac83d2e..3125ebaf 100644
--- a/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemfireDataSourcePostProcessorTest.java
+++ b/spring-data-geode/src/test/java/org/springframework/data/gemfire/client/GemfireDataSourcePostProcessorUnitTests.java
@@ -17,6 +17,7 @@ package org.springframework.data.gemfire.client;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.ArgumentMatchers.same;
@@ -29,6 +30,7 @@ import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.springframework.data.gemfire.util.RuntimeExceptionFactory.newIllegalArgumentException;
@@ -63,24 +65,18 @@ import org.springframework.data.gemfire.client.function.ListRegionsOnServerFunct
import org.springframework.data.gemfire.util.RegionUtils;
/**
- * Unit tests for {@link GemfireDataSourcePostProcessor}.
+ * Unit Tests for {@link GemfireDataSourcePostProcessor}.
*
* @author John Blum
* @see org.junit.Test
+ * @see org.mockito.Mock
* @see org.mockito.Mockito
- * @see org.apache.geode.cache.Region
- * @see org.apache.geode.cache.RegionAttributes
- * @see org.apache.geode.cache.client.ClientCache
- * @see org.apache.geode.cache.client.ClientRegionFactory
- * @see org.apache.geode.cache.execute.Function
- * @see org.springframework.beans.factory.BeanFactory
- * @see org.springframework.beans.factory.config.ConfigurableBeanFactory
+ * @see org.mockito.junit.MockitoJUnitRunner
* @see org.springframework.data.gemfire.client.GemfireDataSourcePostProcessor
- * @see org.springframework.data.gemfire.client.function.ListRegionsOnServerFunction
* @since 1.7.0
*/
@RunWith(MockitoJUnitRunner.class)
-public class GemfireDataSourcePostProcessorTest {
+public class GemfireDataSourcePostProcessorUnitTests {
@Mock
private ConfigurableBeanFactory mockBeanFactory;
@@ -88,6 +84,10 @@ public class GemfireDataSourcePostProcessorTest {
@Mock
private ClientCache mockClientCache;
+ private ClientRegionShortcut getClientRegionShortcut(GemfireDataSourcePostProcessor postProcessor) {
+ return postProcessor.getClientRegionShortcut().orElse(null);
+ }
+
@SuppressWarnings("unchecked")
private Region