Polish for #558.
This commit is contained in:
@@ -22,16 +22,15 @@ import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* The SubscriptionAttributesFactoryBean class is a Spring FactoryBean used for defining and constructing
|
||||
* a GemFire SubscriptionAttributes object, which determines the Subscription policy used by Regions to
|
||||
* declared their data interests.
|
||||
* Spring {@link FactoryBean} used for defining and constructing an Apache Geode {@link SubscriptionAttributes} object,
|
||||
* which determines the subscription policy used by cache Regions declaring their data interests.
|
||||
*
|
||||
* @author Lyndon Adams
|
||||
* @author John Blum
|
||||
* @see org.springframework.beans.factory.FactoryBean
|
||||
* @see org.springframework.beans.factory.InitializingBean
|
||||
* @see org.apache.geode.cache.InterestPolicy
|
||||
* @see org.apache.geode.cache.SubscriptionAttributes
|
||||
* @see org.springframework.beans.factory.FactoryBean
|
||||
* @see org.springframework.beans.factory.InitializingBean
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public class SubscriptionAttributesFactoryBean implements FactoryBean<SubscriptionAttributes>, InitializingBean {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.client.function;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,24 +26,28 @@ import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.execute.Function;
|
||||
import org.apache.geode.cache.execute.FunctionContext;
|
||||
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
/**
|
||||
* ListRegionsOnServerFunction is a GemFire Function class that returns a List of names for all Regions
|
||||
* defined in the GemFire cluster.
|
||||
* {@link ListRegionsOnServerFunction} is an Apache Geode {@link Function}
|
||||
* returning a {@link List} of {@link String names} for all {@link Region Regions}
|
||||
* defined in the Apache Geode cache.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see java.io.Serial
|
||||
* @see org.apache.geode.cache.execute.Function
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ListRegionsOnServerFunction implements Function {
|
||||
public class ListRegionsOnServerFunction implements Function<Object> {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 867530169L;
|
||||
|
||||
public static final String ID = ListRegionsOnServerFunction.class.getName();
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void execute(FunctionContext functionContext) {
|
||||
public void execute(@NonNull FunctionContext functionContext) {
|
||||
|
||||
List<String> regionNames = new ArrayList<>();
|
||||
|
||||
@@ -57,21 +62,33 @@ public class ListRegionsOnServerFunction implements Function {
|
||||
return CacheFactory.getAnyInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return this.getClass().getName();
|
||||
return getClass().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public boolean hasResult() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public boolean isHA() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public boolean optimizeForWrite() {
|
||||
return false;
|
||||
|
||||
@@ -14,11 +14,18 @@ package org.springframework.data.gemfire.function;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.apache.geode.cache.execute.Function;
|
||||
import org.apache.geode.cache.execute.FunctionContext;
|
||||
|
||||
/**
|
||||
* {@link FunctionArgumentResolver} used to resolve {@link Object[] arguments} passed to
|
||||
* an Apache Geode {@link Function} during execution.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.execute.Function
|
||||
* @see org.apache.geode.cache.execute.FunctionContext
|
||||
* @see org.springframework.data.gemfire.function.FunctionArgumentResolver
|
||||
* @since 1.3.0
|
||||
*/
|
||||
class DefaultFunctionArgumentResolver implements FunctionArgumentResolver {
|
||||
|
||||
@@ -14,14 +14,16 @@ package org.springframework.data.gemfire.function;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.apache.geode.cache.execute.Function;
|
||||
import org.apache.geode.cache.execute.FunctionContext;
|
||||
|
||||
/**
|
||||
* The FunctionArgumentResolver interface is a Strategy Interface for resolving Function invocation arguments,
|
||||
* given a {@link FunctionContext}.
|
||||
* The {@link FunctionArgumentResolver} interface is a {@literal Strategy} interface for resolving {@link Function}
|
||||
* invocation arguments from the given {@link FunctionContext}.
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.execute.Function
|
||||
* @see org.apache.geode.cache.execute.FunctionContext
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@@ -29,6 +31,7 @@ interface FunctionArgumentResolver {
|
||||
|
||||
Method getFunctionAnnotatedMethod();
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
Object[] resolveFunctionArguments(FunctionContext functionContext);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.function;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -23,23 +22,25 @@ import org.apache.geode.cache.CacheFactory;
|
||||
import org.apache.geode.cache.execute.FunctionContext;
|
||||
import org.apache.geode.pdx.PdxInstance;
|
||||
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* The PdxFunctionArgumentResolver class is a Spring Data GemFire FunctionArgumentResolver that automatically resolves
|
||||
* PDX types when GemFire is configured with read-serialized set to true, but the application domain classes
|
||||
* are actually on the classpath.
|
||||
* {@link PdxFunctionArgumentResolver} is a {@link FunctionArgumentResolver} that automatically resolves PDX types
|
||||
* when Apache Geode is configured with {@literal read-serialized} set to {@literal true}, but the application
|
||||
* domain model classes are actually on the application classpath.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.function.DefaultFunctionArgumentResolver
|
||||
* @see org.apache.geode.pdx.PdxInstance
|
||||
* @see org.springframework.data.gemfire.function.DefaultFunctionArgumentResolver
|
||||
* @since 1.5.2
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
class PdxFunctionArgumentResolver extends DefaultFunctionArgumentResolver {
|
||||
|
||||
@Override
|
||||
public Object[] resolveFunctionArguments(final FunctionContext functionContext) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object[] resolveFunctionArguments(@NonNull FunctionContext functionContext) {
|
||||
|
||||
Object[] functionArguments = super.resolveFunctionArguments(functionContext);
|
||||
|
||||
@@ -70,6 +71,7 @@ class PdxFunctionArgumentResolver extends DefaultFunctionArgumentResolver {
|
||||
}
|
||||
|
||||
boolean isPdxSerializerConfigured() {
|
||||
|
||||
try {
|
||||
return (CacheFactory.getAnyInstance().getPdxSerializer() != null);
|
||||
}
|
||||
@@ -78,11 +80,6 @@ class PdxFunctionArgumentResolver extends DefaultFunctionArgumentResolver {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadac)
|
||||
* @see #isOnClasspath(String)
|
||||
* @see #functionAnnotatedMethodHasParameterOfType(String)
|
||||
*/
|
||||
boolean isDeserializationNecessary(final String className) {
|
||||
return (isOnClasspath(className) && functionAnnotatedMethodHasParameterOfType(className));
|
||||
}
|
||||
@@ -92,6 +89,7 @@ class PdxFunctionArgumentResolver extends DefaultFunctionArgumentResolver {
|
||||
}
|
||||
|
||||
boolean functionAnnotatedMethodHasParameterOfType(final String className) {
|
||||
|
||||
for (Class<?> parameterType : getFunctionAnnotatedMethod().getParameterTypes()) {
|
||||
if (parameterType.getName().equals(className)) {
|
||||
return true;
|
||||
|
||||
@@ -23,6 +23,9 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.geode.cache.execute.Execution;
|
||||
import org.apache.geode.cache.execute.Function;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
@@ -31,14 +34,20 @@ import org.springframework.core.type.filter.AnnotationTypeFilter;
|
||||
import org.springframework.core.type.filter.AssignableTypeFilter;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.data.gemfire.util.ArrayUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* Annotation based configuration source for function executions
|
||||
* Annotation based configuration source for {@link Function} {@link Execution Executions}.
|
||||
*
|
||||
* @author David Turanski
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.lang.annotation.Annotation
|
||||
* @see org.apache.geode.cache.execute.Execution
|
||||
* @see org.apache.geode.cache.execute.Function
|
||||
* @see org.springframework.data.gemfire.function.config.EnableGemfireFunctionExecutions
|
||||
*/
|
||||
public class AnnotationFunctionExecutionConfigurationSource extends AbstractFunctionExecutionConfigurationSource {
|
||||
|
||||
@@ -50,28 +59,34 @@ public class AnnotationFunctionExecutionConfigurationSource extends AbstractFunc
|
||||
private final AnnotationAttributes attributes;
|
||||
|
||||
/**
|
||||
* Creates a new instance of {@link AnnotationFunctionExecutionConfigurationSource} from
|
||||
* the given {@link AnnotationMetadata} and {@link EnableGemfireFunctionExecutions} annotation.
|
||||
* Constructs a new instance of {@link AnnotationFunctionExecutionConfigurationSource}
|
||||
* from the given {@link AnnotationMetadata} and {@link EnableGemfireFunctionExecutions} annotation.
|
||||
*
|
||||
* @param metadata {@link AnnotationMetadata} for the {@link EnableGemfireFunctionExecutions} annotation;
|
||||
* must not be {@literal null}.
|
||||
* @see org.springframework.core.type.AnnotationMetadata
|
||||
*/
|
||||
public AnnotationFunctionExecutionConfigurationSource(AnnotationMetadata metadata) {
|
||||
public AnnotationFunctionExecutionConfigurationSource(@NonNull AnnotationMetadata metadata) {
|
||||
|
||||
Assert.notNull(metadata, "AnnotationMetadata must not be null");
|
||||
|
||||
this.attributes = AnnotationAttributes.fromMap(
|
||||
metadata.getAnnotationAttributes(EnableGemfireFunctionExecutions.class.getName()));
|
||||
this.attributes = AnnotationAttributes
|
||||
.fromMap(metadata.getAnnotationAttributes(EnableGemfireFunctionExecutions.class.getName()));
|
||||
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Object getSource() {
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Iterable<String> getBasePackages() {
|
||||
|
||||
@@ -100,7 +115,7 @@ public class AnnotationFunctionExecutionConfigurationSource extends AbstractFunc
|
||||
return packages;
|
||||
}
|
||||
|
||||
private boolean areAllEmpty(Object[]... arrays) {
|
||||
private boolean areAllEmpty(@Nullable Object[]... arrays) {
|
||||
|
||||
for (Object[] array : ArrayUtils.nullSafeArray(arrays, Object[].class)) {
|
||||
if (!ArrayUtils.isEmpty(array)) {
|
||||
@@ -111,11 +126,17 @@ public class AnnotationFunctionExecutionConfigurationSource extends AbstractFunc
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Iterable<TypeFilter> getIncludeFilters() {
|
||||
return parseFilters("includeFilters");
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Iterable<TypeFilter> getExcludeFilters() {
|
||||
return parseFilters("excludeFilters");
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
*/
|
||||
package org.springframework.data.gemfire.function.config;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Parser for a <function-executions> bean definition.
|
||||
*
|
||||
@@ -34,6 +34,9 @@ import org.springframework.beans.factory.xml.ParserContext;
|
||||
*/
|
||||
public class FunctionExecutionBeanDefinitionParser implements BeanDefinitionParser {
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
new FunctionExecutionBeanDefinitionRegistrar().registerBeanDefinitions(element, parserContext);
|
||||
|
||||
@@ -51,6 +51,9 @@ import org.w3c.dom.Element;
|
||||
*/
|
||||
public class FunctionExecutionBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata annotationMetadata, BeanDefinitionRegistry registry) {
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.geode.cache.execute.Execution;
|
||||
import org.apache.geode.cache.execute.Function;
|
||||
|
||||
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
|
||||
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
@@ -27,6 +30,7 @@ import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.core.type.filter.AbstractTypeHierarchyTraversingFilter;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.data.gemfire.util.CollectionUtils;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -40,14 +44,16 @@ class FunctionExecutionComponentProvider extends ClassPathScanningCandidateCompo
|
||||
private final Set<Class<? extends Annotation>> functionExecutionAnnotationTypes;
|
||||
|
||||
/**
|
||||
* Creates a new {@link FunctionExecutionComponentProvider} using the given {@link TypeFilter} to include components to be
|
||||
* picked up.
|
||||
* Constructs a new instance of {@link FunctionExecutionComponentProvider} using the given {@link TypeFilter}
|
||||
* to include components to be picked up during the scan.
|
||||
*
|
||||
* @param includeFilters the {@link TypeFilter}s to select function execution interfaces to consider, must not be
|
||||
* {@literal null}.
|
||||
* @param includeFilters the {@link TypeFilter}s to select function execution interfaces to consider;
|
||||
* must not be {@literal null}.
|
||||
* @param functionExecutionAnnotationTypes {@link Set} of {@link Annotation} types denoting Apache Geode
|
||||
* {@link Function} {@link Execution Executions}.
|
||||
*/
|
||||
public FunctionExecutionComponentProvider(Iterable<? extends TypeFilter> includeFilters ,
|
||||
Set<Class<? extends Annotation>> functionExecutionAnnotationTypes) {
|
||||
public FunctionExecutionComponentProvider(@NonNull Iterable<? extends TypeFilter> includeFilters,
|
||||
@NonNull Set<Class<? extends Annotation>> functionExecutionAnnotationTypes) {
|
||||
|
||||
super(false);
|
||||
|
||||
@@ -103,7 +109,6 @@ class FunctionExecutionComponentProvider extends ClassPathScanningCandidateCompo
|
||||
return isTopLevelType;
|
||||
}
|
||||
|
||||
|
||||
// Copy of Spring's AnnotationTypeFilter until SPR-8336 gets resolved.
|
||||
|
||||
/**
|
||||
|
||||
@@ -44,6 +44,9 @@ import org.springframework.util.ReflectionUtils;
|
||||
*/
|
||||
public class GemfireFunctionBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ import org.springframework.core.type.AnnotationMetadata;
|
||||
*/
|
||||
public class GemfireFunctionBeanPostProcessorRegistrar implements ImportBeanDefinitionRegistrar {
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
|
||||
|
||||
|
||||
@@ -10,11 +10,13 @@
|
||||
* 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 org.springframework.data.gemfire.function.config;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.geode.cache.execute.Execution;
|
||||
import org.apache.geode.cache.execute.Function;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.data.gemfire.function.annotation.OnMember;
|
||||
@@ -23,7 +25,7 @@ import org.springframework.data.gemfire.function.execution.GemfireFunctionProxyF
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Base class for {@link OnMember} and {@link OnMembers} Function execution
|
||||
* Abstract base class for {@link OnMember} and {@link OnMembers} {@link Function} {@link Execution}
|
||||
* {@link BeanDefinitionBuilder BeanDefinitionBuilders}.
|
||||
*
|
||||
* @author David Turanski
|
||||
@@ -37,6 +39,9 @@ abstract class MemberBasedFunctionExecutionBeanDefinitionBuilder
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected BeanDefinitionBuilder getGemfireFunctionOperationsBeanDefinitionBuilder(BeanDefinitionRegistry registry) {
|
||||
|
||||
@@ -54,6 +59,9 @@ abstract class MemberBasedFunctionExecutionBeanDefinitionBuilder
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getFunctionProxyFactoryBeanClass() {
|
||||
return GemfireFunctionProxyFactoryBean.class;
|
||||
|
||||
@@ -24,6 +24,9 @@ class OnMemberFunctionExecutionBeanDefinitionBuilder extends MemberBasedFunction
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getGemfireOperationsClass() {
|
||||
return GemfireOnMemberFunctionTemplate.class;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* 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 org.springframework.data.gemfire.function.config;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
@@ -32,6 +31,9 @@ class OnRegionFunctionExecutionBeanDefinitionBuilder extends AbstractFunctionExe
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected BeanDefinitionBuilder getGemfireFunctionOperationsBeanDefinitionBuilder(BeanDefinitionRegistry registry) {
|
||||
|
||||
@@ -45,7 +47,9 @@ class OnRegionFunctionExecutionBeanDefinitionBuilder extends AbstractFunctionExe
|
||||
return functionTemplateBuilder;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getFunctionProxyFactoryBeanClass() {
|
||||
return OnRegionFunctionProxyFactoryBean.class;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
* 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 org.springframework.data.gemfire.function.config;
|
||||
|
||||
import org.springframework.data.gemfire.function.execution.GemfireOnServerFunctionTemplate;
|
||||
@@ -25,6 +24,9 @@ class OnServerFunctionExecutionBeanDefinitionBuilder extends ServerBasedFunction
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getGemfireFunctionOperationsClass() {
|
||||
return GemfireOnServerFunctionTemplate.class;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
* 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 org.springframework.data.gemfire.function.config;
|
||||
|
||||
import org.springframework.data.gemfire.function.execution.GemfireOnServersFunctionTemplate;
|
||||
@@ -25,6 +24,9 @@ class OnServersFunctionExecutionBeanDefinitionBuilder extends ServerBasedFunctio
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getGemfireFunctionOperationsClass() {
|
||||
return GemfireOnServersFunctionTemplate.class;
|
||||
|
||||
@@ -14,6 +14,9 @@ package org.springframework.data.gemfire.function.config;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.geode.cache.execute.Execution;
|
||||
import org.apache.geode.cache.execute.Function;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
@@ -23,7 +26,7 @@ import org.springframework.data.gemfire.function.execution.GemfireFunctionProxyF
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Base class for {@link OnServer} and {@link OnServers} Function execution
|
||||
* Abstract base class for {@link OnServer} and {@link OnServers} {@link Function} {@link Execution}
|
||||
* {@link BeanDefinitionBuilder BeanDefinitionBuilders}.
|
||||
*
|
||||
* @author David Turanski
|
||||
@@ -41,6 +44,9 @@ abstract class ServerBasedFunctionExecutionBeanDefinitionBuilder
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected BeanDefinitionBuilder getGemfireFunctionOperationsBeanDefinitionBuilder(BeanDefinitionRegistry registry) {
|
||||
|
||||
@@ -66,6 +72,9 @@ abstract class ServerBasedFunctionExecutionBeanDefinitionBuilder
|
||||
return functionTemplateBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getFunctionProxyFactoryBeanClass() {
|
||||
return GemfireFunctionProxyFactoryBean.class;
|
||||
|
||||
@@ -18,14 +18,14 @@ package org.springframework.data.gemfire.function.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.core.type.filter.TypeFilter;
|
||||
import org.springframework.data.gemfire.function.config.TypeFilterParser.Type;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
@@ -55,11 +55,17 @@ public class XmlFunctionExecutionConfigurationSource extends AbstractFunctionExe
|
||||
this.excludeFilters = parser.parseTypeFilters(element, Type.EXCLUDE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Object getSource() {
|
||||
return this.parserContext.extractSource(this.element);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Iterable<String> getBasePackages() {
|
||||
|
||||
@@ -68,12 +74,17 @@ public class XmlFunctionExecutionConfigurationSource extends AbstractFunctionExe
|
||||
return Arrays.asList(StringUtils.delimitedListToStringArray(attribute, ",", " "));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Iterable<TypeFilter> getIncludeFilters() {
|
||||
return this.includeFilters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Iterable<TypeFilter> getExcludeFilters() {
|
||||
return this.excludeFilters;
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.mapping;
|
||||
|
||||
import org.apache.geode.pdx.PdxReader;
|
||||
|
||||
import org.springframework.data.mapping.model.PropertyValueProvider;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -33,15 +33,20 @@ class GemfirePropertyValueProvider implements PropertyValueProvider<GemfirePersi
|
||||
private final PdxReader reader;
|
||||
|
||||
/**
|
||||
* Creates a new {@link GemfirePropertyValueProvider} with the given {@link PdxReader}.
|
||||
* Constructs a new instance of {@link GemfirePropertyValueProvider} with the given {@link PdxReader}.
|
||||
*
|
||||
* @param reader must not be {@literal null}.
|
||||
* @param reader {@link PdxReader} used to read values from PDX serialized bytes; must not be {@literal null}.
|
||||
* @throws IllegalArgumentException if the {@link PdxReader} is {@literal null}.
|
||||
* @see org.apache.geode.pdx.PdxReader
|
||||
*/
|
||||
public GemfirePropertyValueProvider(PdxReader reader) {
|
||||
public GemfirePropertyValueProvider(@NonNull PdxReader reader) {
|
||||
Assert.notNull(reader, "PdxReader must not be null");
|
||||
this.reader = reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getPropertyValue(GemfirePersistentProperty property) {
|
||||
|
||||
@@ -22,37 +22,57 @@ import org.springframework.expression.PropertyAccessor;
|
||||
import org.springframework.expression.TypedValue;
|
||||
|
||||
/**
|
||||
* {@link PropertyAccessor} to read values from a {@link PdxReader}.
|
||||
* {@link PropertyAccessor} used to read values from a {@link PdxReader}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.pdx.PdxReader
|
||||
* @see org.springframework.expression.PropertyAccessor
|
||||
*/
|
||||
enum PdxReaderPropertyAccessor implements PropertyAccessor {
|
||||
|
||||
INSTANCE;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Class<?>[] getSpecificTargetClasses() {
|
||||
return new Class<?>[] { PdxReader.class };
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public boolean canRead(EvaluationContext evaluationContext, Object target, String name) {
|
||||
return ((PdxReader) target).hasField(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public TypedValue read(EvaluationContext evaluationContext, Object target, String name) {
|
||||
|
||||
Object object = ((PdxReader) target).readObject(name);
|
||||
|
||||
return object != null ? new TypedValue(object) : TypedValue.NULL;
|
||||
return object != null
|
||||
? new TypedValue(object)
|
||||
: TypedValue.NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public boolean canWrite(EvaluationContext evaluationContext, Object target, String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public void write(EvaluationContext evaluationContext, Object target, String name, Object newValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.mapping;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -25,13 +24,16 @@ import java.util.Optional;
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.springframework.data.mapping.context.MappingContext;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Simple value object to abstract access to regions by name and mapped type.
|
||||
* Simple value object to abstract access to {@link Region Regions} by {@link String name} and mapped {@link Class type}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author John Blum
|
||||
* @see java.lang.Iterable
|
||||
* @see org.apache.geode.cache.Region
|
||||
*/
|
||||
public class Regions implements Iterable<Region<?, ?>> {
|
||||
|
||||
@@ -40,14 +42,17 @@ public class Regions implements Iterable<Region<?, ?>> {
|
||||
private final MappingContext<? extends GemfirePersistentEntity<?>, ?> mappingContext;
|
||||
|
||||
/**
|
||||
* Creates a new {@link Regions} wrapper for the given {@link Region}s and
|
||||
* {@link MappingContext}.
|
||||
* Constructs a new instance of the {@link Regions} wrapper for the given {@link Region Regions}
|
||||
* and {@link MappingContext}.
|
||||
*
|
||||
* @param regions must not be {@literal null}.
|
||||
* @param mappingContext must not be {@literal null}.
|
||||
* @param regions {@link Iterable} of cache {@link Region Regions}; must not be {@literal null}.
|
||||
* @param mappingContext Spring Data {@link MappingContext} used for data mapping; must not be {@literal null}.
|
||||
* @see org.springframework.data.mapping.context.MappingContext
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see java.lang.Iterable
|
||||
*/
|
||||
public Regions(Iterable<Region<?, ?>> regions,
|
||||
MappingContext<? extends GemfirePersistentEntity<?>, ?> mappingContext) {
|
||||
public Regions(@NonNull Iterable<Region<?, ?>> regions,
|
||||
@NonNull MappingContext<? extends GemfirePersistentEntity<?>, ?> mappingContext) {
|
||||
|
||||
Assert.notNull(regions, "Regions must not be null");
|
||||
Assert.notNull(mappingContext, "MappingContext must not be null");
|
||||
@@ -100,6 +105,9 @@ public class Regions implements Iterable<Region<?, ?>> {
|
||||
return (Region<S, T>) this.regions.get(namePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Iterator<Region<?, ?>> iterator() {
|
||||
return this.regions.values().iterator();
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.gemfire.repository.query;
|
||||
import org.springframework.data.gemfire.mapping.GemfirePersistentEntity;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
import org.springframework.data.repository.core.support.PersistentEntityInformation;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
/**
|
||||
* Implementation of {@link GemfireEntityInformation} and Spring Data's {@link PersistentEntityInformation}
|
||||
@@ -36,15 +37,20 @@ public class DefaultGemfireEntityInformation<T, ID> extends PersistentEntityInfo
|
||||
private final GemfirePersistentEntity<T> entity;
|
||||
|
||||
/**
|
||||
* Creates a new {@link DefaultGemfireEntityInformation}.
|
||||
* Constructs a new instance of {@link DefaultGemfireEntityInformation}
|
||||
* for the given {@link GemfirePersistentEntity}.
|
||||
*
|
||||
* @param entity must not be {@literal null}.
|
||||
* @param entity {@link GemfirePersistentEntity} to wrap; must not be {@literal null}.
|
||||
* @see org.springframework.data.gemfire.mapping.GemfirePersistentEntity
|
||||
*/
|
||||
public DefaultGemfireEntityInformation(GemfirePersistentEntity<T> entity) {
|
||||
public DefaultGemfireEntityInformation(@NonNull GemfirePersistentEntity<T> entity) {
|
||||
super(entity);
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public String getRegionName() {
|
||||
return entity.getRegionName();
|
||||
|
||||
@@ -119,16 +119,25 @@ public class GemfireRepositoryFactory extends RepositoryFactorySupport {
|
||||
return this.regions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public <T, ID> GemfireEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
return new DefaultGemfireEntityInformation<>(resolvePersistentEntity(domainClass));
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> getRepositoryBaseClass(RepositoryMetadata metadata) {
|
||||
return SimpleGemfireRepository.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
protected Object getTargetRepository(RepositoryInformation repositoryInformation) {
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ public class CacheServerFactoryBean extends AbstractFactoryBeanSupport<CacheServ
|
||||
|
||||
private List<CacheServerConfigurer> cacheServerConfigurers = Collections.emptyList();
|
||||
|
||||
private CacheServerConfigurer compositeCacheServerConfigurer = (beanName, bean) ->
|
||||
private final CacheServerConfigurer compositeCacheServerConfigurer = (beanName, bean) ->
|
||||
nullSafeCollection(cacheServerConfigurers).forEach(cacheServerConfigurer ->
|
||||
cacheServerConfigurer.configure(beanName, bean));
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.util;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -23,12 +22,13 @@ import java.io.Reader;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The PropertiesBuilder class is a Builder for {@link java.util.Properties}.
|
||||
* Builder for {@link java.util.Properties}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.util.Properties
|
||||
@@ -39,38 +39,39 @@ import org.springframework.util.StringUtils;
|
||||
public class PropertiesBuilder implements FactoryBean<Properties> {
|
||||
|
||||
/**
|
||||
* Factory method to create a default {@link PropertiesBuilder} instance.
|
||||
* Factory method used to create a default {@link PropertiesBuilder} instance.
|
||||
*
|
||||
* @return an instance of the {@link PropertiesBuilder} class with not {@link Properties}.
|
||||
* @see #PropertiesBuilder()
|
||||
*/
|
||||
public static PropertiesBuilder create() {
|
||||
public static @NonNull PropertiesBuilder create() {
|
||||
return new PropertiesBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to create an instance of {@link PropertiesBuilder} initialized with the given {@link Properties}.
|
||||
* Factory method used to create an instance of {@link PropertiesBuilder} initialized with
|
||||
* the given {@link Properties}.
|
||||
*
|
||||
* @param properties {@link Properties} used as the default properties of the constructed {@link PropertiesBuilder}.
|
||||
* @return an instance of {@link PropertiesBuilder} initialized with the given {@link Properties}.
|
||||
* @see java.util.Properties
|
||||
* @see #PropertiesBuilder(Properties)
|
||||
*/
|
||||
public static PropertiesBuilder from(Properties properties) {
|
||||
public static @NonNull PropertiesBuilder from(@NonNull Properties properties) {
|
||||
return new PropertiesBuilder(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs and initializes a {@link PropertiesBuilder} containing all properties
|
||||
* Constructs a new instance of {@link PropertiesBuilder} initialized with all properties
|
||||
* from the given {@link InputStream}.
|
||||
*
|
||||
* @param in {@link InputStream} source containing properties to use as the defaults for the constructed builder.
|
||||
* @return a {@link PropertiesBuilder} initialized with properties from the given {@link InputStream}.
|
||||
* @throws IllegalArgumentException if the {@link InputStream} cannot be read.
|
||||
* @see java.io.InputStream
|
||||
* @see java.util.Properties#load(InputStream)
|
||||
* @see java.io.InputStream
|
||||
*/
|
||||
public static PropertiesBuilder from(InputStream in) {
|
||||
public static @NonNull PropertiesBuilder from(@NonNull InputStream in) {
|
||||
|
||||
try {
|
||||
Properties defaults = new Properties();
|
||||
@@ -83,16 +84,16 @@ public class PropertiesBuilder implements FactoryBean<Properties> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs and initializes a {@link PropertiesBuilder} containing all properties
|
||||
* Constructs a new isntance of {@link PropertiesBuilder} initialized with all properties
|
||||
* from the given {@link Reader}.
|
||||
*
|
||||
* @param reader {@link Reader} source containing properties to use as the defaults for the constructed builder.
|
||||
* @return a {@link PropertiesBuilder} initialized with properties from the given {@link Reader}.
|
||||
* @throws IllegalArgumentException if the {@link Reader} cannot be read.
|
||||
* @see java.io.Reader
|
||||
* @see java.util.Properties#load(Reader)
|
||||
* @see java.io.Reader
|
||||
*/
|
||||
public static PropertiesBuilder from(Reader reader) {
|
||||
public static @NonNull PropertiesBuilder from(@NonNull Reader reader) {
|
||||
|
||||
try {
|
||||
Properties defaults = new Properties();
|
||||
@@ -105,17 +106,17 @@ public class PropertiesBuilder implements FactoryBean<Properties> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs and initializes a {@link PropertiesBuilder} containing all properties
|
||||
* Constructs a new instance of {@link PropertiesBuilder} initialized with all properties
|
||||
* from the given {@link InputStream} in XML format.
|
||||
*
|
||||
* @param xml {@link InputStream} source containing properties in XML format to use as defaults
|
||||
* for the constructed builder.
|
||||
* @return a {@link PropertiesBuilder} initialized with properties from the given XML {@link InputStream}.
|
||||
* @throws IllegalArgumentException if the XML {@link InputStream} cannot be read.
|
||||
* @see java.io.InputStream
|
||||
* @see java.util.Properties#loadFromXML(InputStream)
|
||||
* @see java.io.InputStream
|
||||
*/
|
||||
public static PropertiesBuilder fromXml(InputStream xml) {
|
||||
public static @NonNull PropertiesBuilder fromXml(@NonNull InputStream xml) {
|
||||
|
||||
try {
|
||||
Properties defaults = new Properties();
|
||||
@@ -130,46 +131,56 @@ public class PropertiesBuilder implements FactoryBean<Properties> {
|
||||
private final Properties properties;
|
||||
|
||||
/**
|
||||
* Constructs an instance of the {@link PropertiesBuilder} class.
|
||||
* Constructs a new instance of {@link PropertiesBuilder}.
|
||||
*/
|
||||
public PropertiesBuilder() {
|
||||
this.properties = new Properties();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of the {@link PropertiesBuilder} class initialized with the default {@link Properties}.
|
||||
* Constructs a new instance of {@link PropertiesBuilder} initialized with the default {@link Properties}.
|
||||
*
|
||||
* @param defaults {@link Properties} used as the defaults.
|
||||
* @throws NullPointerException if the {@link Properties} reference is {@literal null}.
|
||||
* @see java.util.Properties
|
||||
*/
|
||||
public PropertiesBuilder(Properties defaults) {
|
||||
public PropertiesBuilder(@NonNull Properties defaults) {
|
||||
this.properties = new Properties();
|
||||
this.properties.putAll(defaults);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an instance of the {@link PropertiesBuilder} class initialized with the given
|
||||
* {@link PropertiesBuilder} providing the default {@link Properties} for this builder.
|
||||
* Constructs a new instance of {@link PropertiesBuilder} initialized with the given {@link PropertiesBuilder}
|
||||
* providing the default {@link Properties} for {@literal this} builder.
|
||||
*
|
||||
* @param builder {@link PropertiesBuilder} providing the default {@link Properties} for this builder.
|
||||
* @throws NullPointerException if the {@link PropertiesBuilder} reference is {@literal null}.
|
||||
* @see #PropertiesBuilder(Properties)
|
||||
*/
|
||||
public PropertiesBuilder(PropertiesBuilder builder) {
|
||||
@SuppressWarnings("all")
|
||||
public PropertiesBuilder(@NonNull PropertiesBuilder builder) {
|
||||
this(builder.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Properties getObject() throws Exception {
|
||||
return build();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return this.properties != null ? this.properties.getClass() : Properties.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user