Skip to content

Commit 093edb4

Browse files
committed
Polish for #558.
1 parent 5b886b0 commit 093edb4

25 files changed

+250
-90
lines changed

spring-data-geode/src/main/java/org/springframework/data/gemfire/SubscriptionAttributesFactoryBean.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@
2222
import org.springframework.beans.factory.InitializingBean;
2323

2424
/**
25-
* The SubscriptionAttributesFactoryBean class is a Spring FactoryBean used for defining and constructing
26-
* a GemFire SubscriptionAttributes object, which determines the Subscription policy used by Regions to
27-
* declared their data interests.
25+
* Spring {@link FactoryBean} used for defining and constructing an Apache Geode {@link SubscriptionAttributes} object,
26+
* which determines the subscription policy used by cache Regions declaring their data interests.
2827
*
2928
* @author Lyndon Adams
3029
* @author John Blum
31-
* @see org.springframework.beans.factory.FactoryBean
32-
* @see org.springframework.beans.factory.InitializingBean
3330
* @see org.apache.geode.cache.InterestPolicy
3431
* @see org.apache.geode.cache.SubscriptionAttributes
32+
* @see org.springframework.beans.factory.FactoryBean
33+
* @see org.springframework.beans.factory.InitializingBean
3534
* @since 1.3.0
3635
*/
3736
public class SubscriptionAttributesFactoryBean implements FactoryBean<SubscriptionAttributes>, InitializingBean {

spring-data-geode/src/main/java/org/springframework/data/gemfire/client/function/ListRegionsOnServerFunction.java

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.springframework.data.gemfire.client.function;
1818

19+
import java.io.Serial;
1920
import java.util.ArrayList;
2021
import java.util.List;
2122

@@ -25,24 +26,28 @@
2526
import org.apache.geode.cache.execute.Function;
2627
import org.apache.geode.cache.execute.FunctionContext;
2728

29+
import org.springframework.lang.NonNull;
30+
2831
/**
29-
* ListRegionsOnServerFunction is a GemFire Function class that returns a List of names for all Regions
30-
* defined in the GemFire cluster.
32+
* {@link ListRegionsOnServerFunction} is an Apache Geode {@link Function}
33+
* returning a {@link List} of {@link String names} for all {@link Region Regions}
34+
* defined in the Apache Geode cache.
3135
*
3236
* @author David Turanski
3337
* @author John Blum
38+
* @see java.io.Serial
3439
* @see org.apache.geode.cache.execute.Function
3540
*/
36-
@SuppressWarnings("serial")
37-
public class ListRegionsOnServerFunction implements Function {
41+
public class ListRegionsOnServerFunction implements Function<Object> {
3842

43+
@Serial
3944
private static final long serialVersionUID = 867530169L;
4045

4146
public static final String ID = ListRegionsOnServerFunction.class.getName();
4247

4348
@Override
4449
@SuppressWarnings("unchecked")
45-
public void execute(FunctionContext functionContext) {
50+
public void execute(@NonNull FunctionContext functionContext) {
4651

4752
List<String> regionNames = new ArrayList<>();
4853

@@ -57,21 +62,33 @@ Cache getCache() {
5762
return CacheFactory.getAnyInstance();
5863
}
5964

65+
/**
66+
* @inheritDoc
67+
*/
6068
@Override
6169
public String getId() {
62-
return this.getClass().getName();
70+
return getClass().getName();
6371
}
6472

73+
/**
74+
* @inheritDoc
75+
*/
6576
@Override
6677
public boolean hasResult() {
6778
return true;
6879
}
6980

81+
/**
82+
* @inheritDoc
83+
*/
7084
@Override
7185
public boolean isHA() {
7286
return false;
7387
}
7488

89+
/**
90+
* @inheritDoc
91+
*/
7592
@Override
7693
public boolean optimizeForWrite() {
7794
return false;

spring-data-geode/src/main/java/org/springframework/data/gemfire/function/DefaultFunctionArgumentResolver.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@
1414

1515
import java.lang.reflect.Method;
1616

17+
import org.apache.geode.cache.execute.Function;
1718
import org.apache.geode.cache.execute.FunctionContext;
1819

1920
/**
21+
* {@link FunctionArgumentResolver} used to resolve {@link Object[] arguments} passed to
22+
* an Apache Geode {@link Function} during execution.
23+
*
2024
* @author David Turanski
2125
* @author John Blum
26+
* @see org.apache.geode.cache.execute.Function
27+
* @see org.apache.geode.cache.execute.FunctionContext
28+
* @see org.springframework.data.gemfire.function.FunctionArgumentResolver
2229
* @since 1.3.0
2330
*/
2431
class DefaultFunctionArgumentResolver implements FunctionArgumentResolver {

spring-data-geode/src/main/java/org/springframework/data/gemfire/function/FunctionArgumentResolver.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,24 @@
1414

1515
import java.lang.reflect.Method;
1616

17+
import org.apache.geode.cache.execute.Function;
1718
import org.apache.geode.cache.execute.FunctionContext;
1819

1920
/**
20-
* The FunctionArgumentResolver interface is a Strategy Interface for resolving Function invocation arguments,
21-
* given a {@link FunctionContext}.
21+
* The {@link FunctionArgumentResolver} interface is a {@literal Strategy} interface for resolving {@link Function}
22+
* invocation arguments from the given {@link FunctionContext}.
2223
*
2324
* @author David Turanski
2425
* @author John Blum
26+
* @see org.apache.geode.cache.execute.Function
2527
* @see org.apache.geode.cache.execute.FunctionContext
2628
* @since 1.3.0
2729
*/
2830
interface FunctionArgumentResolver {
2931

3032
Method getFunctionAnnotatedMethod();
3133

34+
@SuppressWarnings("rawtypes")
3235
Object[] resolveFunctionArguments(FunctionContext functionContext);
3336

3437
}

spring-data-geode/src/main/java/org/springframework/data/gemfire/function/PdxFunctionArgumentResolver.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
package org.springframework.data.gemfire.function;
1817

1918
import java.lang.reflect.Method;
@@ -23,23 +22,25 @@
2322
import org.apache.geode.cache.execute.FunctionContext;
2423
import org.apache.geode.pdx.PdxInstance;
2524

25+
import org.springframework.lang.NonNull;
2626
import org.springframework.util.ClassUtils;
2727

2828
/**
29-
* The PdxFunctionArgumentResolver class is a Spring Data GemFire FunctionArgumentResolver that automatically resolves
30-
* PDX types when GemFire is configured with read-serialized set to true, but the application domain classes
31-
* are actually on the classpath.
29+
* {@link PdxFunctionArgumentResolver} is a {@link FunctionArgumentResolver} that automatically resolves PDX types
30+
* when Apache Geode is configured with {@literal read-serialized} set to {@literal true}, but the application
31+
* domain model classes are actually on the application classpath.
3232
*
3333
* @author John Blum
34-
* @see org.springframework.data.gemfire.function.DefaultFunctionArgumentResolver
3534
* @see org.apache.geode.pdx.PdxInstance
35+
* @see org.springframework.data.gemfire.function.DefaultFunctionArgumentResolver
3636
* @since 1.5.2
3737
*/
3838
@SuppressWarnings("unused")
3939
class PdxFunctionArgumentResolver extends DefaultFunctionArgumentResolver {
4040

4141
@Override
42-
public Object[] resolveFunctionArguments(final FunctionContext functionContext) {
42+
@SuppressWarnings("rawtypes")
43+
public Object[] resolveFunctionArguments(@NonNull FunctionContext functionContext) {
4344

4445
Object[] functionArguments = super.resolveFunctionArguments(functionContext);
4546

@@ -70,6 +71,7 @@ public Method getFunctionAnnotatedMethod() {
7071
}
7172

7273
boolean isPdxSerializerConfigured() {
74+
7375
try {
7476
return (CacheFactory.getAnyInstance().getPdxSerializer() != null);
7577
}
@@ -78,11 +80,6 @@ boolean isPdxSerializerConfigured() {
7880
}
7981
}
8082

81-
/*
82-
* (non-Javadac)
83-
* @see #isOnClasspath(String)
84-
* @see #functionAnnotatedMethodHasParameterOfType(String)
85-
*/
8683
boolean isDeserializationNecessary(final String className) {
8784
return (isOnClasspath(className) && functionAnnotatedMethodHasParameterOfType(className));
8885
}
@@ -92,6 +89,7 @@ boolean isOnClasspath(final String className) {
9289
}
9390

9491
boolean functionAnnotatedMethodHasParameterOfType(final String className) {
92+
9593
for (Class<?> parameterType : getFunctionAnnotatedMethod().getParameterTypes()) {
9694
if (parameterType.getName().equals(className)) {
9795
return true;

spring-data-geode/src/main/java/org/springframework/data/gemfire/function/config/AnnotationFunctionExecutionConfigurationSource.java

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
import java.util.List;
2424
import java.util.Set;
2525

26+
import org.apache.geode.cache.execute.Execution;
27+
import org.apache.geode.cache.execute.Function;
28+
2629
import org.springframework.beans.BeanUtils;
2730
import org.springframework.context.annotation.FilterType;
2831
import org.springframework.core.annotation.AnnotationAttributes;
@@ -31,14 +34,20 @@
3134
import org.springframework.core.type.filter.AssignableTypeFilter;
3235
import org.springframework.core.type.filter.TypeFilter;
3336
import org.springframework.data.gemfire.util.ArrayUtils;
37+
import org.springframework.lang.NonNull;
38+
import org.springframework.lang.Nullable;
3439
import org.springframework.util.Assert;
3540
import org.springframework.util.ClassUtils;
3641

3742
/**
38-
* Annotation based configuration source for function executions
43+
* Annotation based configuration source for {@link Function} {@link Execution Executions}.
3944
*
4045
* @author David Turanski
41-
*
46+
* @author John Blum
47+
* @see java.lang.annotation.Annotation
48+
* @see org.apache.geode.cache.execute.Execution
49+
* @see org.apache.geode.cache.execute.Function
50+
* @see org.springframework.data.gemfire.function.config.EnableGemfireFunctionExecutions
4251
*/
4352
public class AnnotationFunctionExecutionConfigurationSource extends AbstractFunctionExecutionConfigurationSource {
4453

@@ -50,28 +59,34 @@ public class AnnotationFunctionExecutionConfigurationSource extends AbstractFunc
5059
private final AnnotationAttributes attributes;
5160

5261
/**
53-
* Creates a new instance of {@link AnnotationFunctionExecutionConfigurationSource} from
54-
* the given {@link AnnotationMetadata} and {@link EnableGemfireFunctionExecutions} annotation.
62+
* Constructs a new instance of {@link AnnotationFunctionExecutionConfigurationSource}
63+
* from the given {@link AnnotationMetadata} and {@link EnableGemfireFunctionExecutions} annotation.
5564
*
5665
* @param metadata {@link AnnotationMetadata} for the {@link EnableGemfireFunctionExecutions} annotation;
5766
* must not be {@literal null}.
5867
* @see org.springframework.core.type.AnnotationMetadata
5968
*/
60-
public AnnotationFunctionExecutionConfigurationSource(AnnotationMetadata metadata) {
69+
public AnnotationFunctionExecutionConfigurationSource(@NonNull AnnotationMetadata metadata) {
6170

6271
Assert.notNull(metadata, "AnnotationMetadata must not be null");
6372

64-
this.attributes = AnnotationAttributes.fromMap(
65-
metadata.getAnnotationAttributes(EnableGemfireFunctionExecutions.class.getName()));
73+
this.attributes = AnnotationAttributes
74+
.fromMap(metadata.getAnnotationAttributes(EnableGemfireFunctionExecutions.class.getName()));
6675

6776
this.metadata = metadata;
6877
}
6978

79+
/**
80+
* @inheritDoc
81+
*/
7082
@Override
7183
public Object getSource() {
7284
return this.metadata;
7385
}
7486

87+
/**
88+
* @inheritDoc
89+
*/
7590
@Override
7691
public Iterable<String> getBasePackages() {
7792

@@ -100,7 +115,7 @@ public Iterable<String> getBasePackages() {
100115
return packages;
101116
}
102117

103-
private boolean areAllEmpty(Object[]... arrays) {
118+
private boolean areAllEmpty(@Nullable Object[]... arrays) {
104119

105120
for (Object[] array : ArrayUtils.nullSafeArray(arrays, Object[].class)) {
106121
if (!ArrayUtils.isEmpty(array)) {
@@ -111,11 +126,17 @@ private boolean areAllEmpty(Object[]... arrays) {
111126
return true;
112127
}
113128

129+
/**
130+
* @inheritDoc
131+
*/
114132
@Override
115133
public Iterable<TypeFilter> getIncludeFilters() {
116134
return parseFilters("includeFilters");
117135
}
118136

137+
/**
138+
* @inheritDoc
139+
*/
119140
@Override
120141
public Iterable<TypeFilter> getExcludeFilters() {
121142
return parseFilters("excludeFilters");

spring-data-geode/src/main/java/org/springframework/data/gemfire/function/config/FunctionExecutionBeanDefinitionParser.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
*/
1717
package org.springframework.data.gemfire.function.config;
1818

19-
import org.w3c.dom.Element;
20-
2119
import org.springframework.beans.factory.config.BeanDefinition;
2220
import org.springframework.beans.factory.xml.BeanDefinitionParser;
2321
import org.springframework.beans.factory.xml.ParserContext;
2422

23+
import org.w3c.dom.Element;
24+
2525
/**
2626
* Parser for a &lt;function-executions&gt; bean definition.
2727
*
@@ -34,6 +34,9 @@
3434
*/
3535
public class FunctionExecutionBeanDefinitionParser implements BeanDefinitionParser {
3636

37+
/**
38+
* @inheritDoc
39+
*/
3740
@Override
3841
public BeanDefinition parse(Element element, ParserContext parserContext) {
3942
new FunctionExecutionBeanDefinitionRegistrar().registerBeanDefinitions(element, parserContext);

spring-data-geode/src/main/java/org/springframework/data/gemfire/function/config/FunctionExecutionBeanDefinitionRegistrar.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
*/
5252
public class FunctionExecutionBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {
5353

54+
/**
55+
* @inheritDoc
56+
*/
5457
@Override
5558
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
5659

spring-data-geode/src/main/java/org/springframework/data/gemfire/function/config/FunctionExecutionComponentProvider.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import java.util.List;
2020
import java.util.Set;
2121

22+
import org.apache.geode.cache.execute.Execution;
23+
import org.apache.geode.cache.execute.Function;
24+
2225
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
2326
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
2427
import org.springframework.core.type.AnnotationMetadata;
@@ -27,6 +30,7 @@
2730
import org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter;
2831
import org.springframework.core.type.filter.TypeFilter;
2932
import org.springframework.data.gemfire.util.CollectionUtils;
33+
import org.springframework.lang.NonNull;
3034
import org.springframework.util.Assert;
3135

3236
/**
@@ -40,14 +44,16 @@ class FunctionExecutionComponentProvider extends ClassPathScanningCandidateCompo
4044
private final Set<Class<? extends Annotation>> functionExecutionAnnotationTypes;
4145

4246
/**
43-
* Creates a new {@link FunctionExecutionComponentProvider} using the given {@link TypeFilter} to include components to be
44-
* picked up.
47+
* Constructs a new instance of {@link FunctionExecutionComponentProvider} using the given {@link TypeFilter}
48+
* to include components to be picked up during the scan.
4549
*
46-
* @param includeFilters the {@link TypeFilter}s to select function execution interfaces to consider, must not be
47-
* {@literal null}.
50+
* @param includeFilters the {@link TypeFilter}s to select function execution interfaces to consider;
51+
* must not be {@literal null}.
52+
* @param functionExecutionAnnotationTypes {@link Set} of {@link Annotation} types denoting Apache Geode
53+
* {@link Function} {@link Execution Executions}.
4854
*/
49-
public FunctionExecutionComponentProvider(Iterable<? extends TypeFilter> includeFilters ,
50-
Set<Class<? extends Annotation>> functionExecutionAnnotationTypes) {
55+
public FunctionExecutionComponentProvider(@NonNull Iterable<? extends TypeFilter> includeFilters,
56+
@NonNull Set<Class<? extends Annotation>> functionExecutionAnnotationTypes) {
5157

5258
super(false);
5359

@@ -103,7 +109,6 @@ protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
103109
return isTopLevelType;
104110
}
105111

106-
107112
// Copy of Spring's AnnotationTypeFilter until SPR-8336 gets resolved.
108113

109114
/**

0 commit comments

Comments
 (0)