SGF-602 - Rename @EnableIndexes to @EnableIndexing.
(cherry picked from commit cd92d4b373a46cf1ee91ddb30b01a2b285703107) Signed-off-by: John Blum <jblum@pivotal.io>
This commit is contained in:
@@ -27,9 +27,9 @@ import java.lang.annotation.Target;
|
||||
import org.apache.geode.cache.query.Index;
|
||||
|
||||
/**
|
||||
* The {@link EnableIndexes} annotation marks a Spring {@link org.springframework.context.annotation.Configuration @Configuration}
|
||||
* The {@link EnableIndexing} annotation marks a Spring {@link org.springframework.context.annotation.Configuration @Configuration}
|
||||
* annotated application class to enable the creation of GemFire/Geode Indexes based on application persistent entity
|
||||
* field/property annotations, such as the {@link @Id} and @Indexed annotations.
|
||||
* field/property annotations, such as the {@link @Id}, {@link @Indexed} and {@link @LuceneIndex} annotations.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.data.gemfire.config.annotation.IndexConfiguration
|
||||
@@ -41,7 +41,7 @@ import org.apache.geode.cache.query.Index;
|
||||
@Inherited
|
||||
@Documented
|
||||
@SuppressWarnings({ "unused" })
|
||||
public @interface EnableIndexes {
|
||||
public @interface EnableIndexing {
|
||||
|
||||
/**
|
||||
* Determines whether all GemFire/Geode {@link Index Indexes} will be defined before created.
|
||||
@@ -42,7 +42,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The {@link IndexConfiguration} class is a Spring {@link org.springframework.context.annotation.ImportBeanDefinitionRegistrar}
|
||||
* and extension of {@link EntityDefinedRegionsConfiguration} used in the {@link EnableIndexes} annotation
|
||||
* and extension of {@link EntityDefinedRegionsConfiguration} used in the {@link EnableIndexing} annotation
|
||||
* to dynamically create GemFire/Geode {@link org.apache.geode.cache.Region} {@link Index Indexes} based on
|
||||
* {@link GemfirePersistentEntity} {@link GemfirePersistentProperty} annotations.
|
||||
*
|
||||
@@ -71,12 +71,12 @@ public class IndexConfiguration extends EntityDefinedRegionsConfiguration {
|
||||
*
|
||||
* @return the {@link Annotation} {@link Class type} that configures and creates {@link Region Region} Indexes
|
||||
* from application persistent entity properties.
|
||||
* @see org.springframework.data.gemfire.config.annotation.EnableIndexes
|
||||
* @see EnableIndexing
|
||||
* @see java.lang.annotation.Annotation
|
||||
* @see java.lang.Class
|
||||
*/
|
||||
protected Class<? extends Annotation> getEnableIndexesAnnotationType() {
|
||||
return EnableIndexes.class;
|
||||
protected Class<? extends Annotation> getEnableIndexingAnnotationType() {
|
||||
return EnableIndexing.class;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,11 +85,11 @@ public class IndexConfiguration extends EntityDefinedRegionsConfiguration {
|
||||
*
|
||||
* @return the name of the {@link Annotation} {@link Class type} that configures and creates {@link Region Region}
|
||||
* Indexes from application persistent entity properties.
|
||||
* @see #getEnableIndexesAnnotationType()
|
||||
* @see #getEnableIndexingAnnotationType()
|
||||
* @see java.lang.Class#getName()
|
||||
*/
|
||||
protected String getEnableIndexesAnnotationTypeName() {
|
||||
return getEnableIndexesAnnotationType().getName();
|
||||
protected String getEnableIndexingAnnotationTypeName() {
|
||||
return getEnableIndexingAnnotationType().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,12 +98,12 @@ public class IndexConfiguration extends EntityDefinedRegionsConfiguration {
|
||||
*
|
||||
* @return the simple name of the {@link Annotation} {@link Class type} that configures and creates
|
||||
* {@link Region Region} Indexes from application persistent entity properties.
|
||||
* @see #getEnableIndexesAnnotationType()
|
||||
* @see #getEnableIndexingAnnotationType()
|
||||
* @see java.lang.Class#getSimpleName()
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
protected String getEnableIndexesAnnotationTypeSimpleName() {
|
||||
return getEnableIndexesAnnotationType().getSimpleName();
|
||||
protected String getEnableIndexingAnnotationTypeSimpleName() {
|
||||
return getEnableIndexingAnnotationType().getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,21 +116,21 @@ public class IndexConfiguration extends EntityDefinedRegionsConfiguration {
|
||||
GemfirePersistentEntity<?> localPersistentEntity =
|
||||
super.postProcess(importingClassMetadata, registry, persistentEntity);
|
||||
|
||||
if (isAnnotationPresent(importingClassMetadata, getEnableIndexesAnnotationTypeName())) {
|
||||
AnnotationAttributes enableIndexesAttributes =
|
||||
getAnnotationAttributes(importingClassMetadata, getEnableIndexesAnnotationTypeName());
|
||||
if (isAnnotationPresent(importingClassMetadata, getEnableIndexingAnnotationTypeName())) {
|
||||
AnnotationAttributes enableIndexingAttributes =
|
||||
getAnnotationAttributes(importingClassMetadata, getEnableIndexingAnnotationTypeName());
|
||||
|
||||
localPersistentEntity.doWithProperties((PropertyHandler<GemfirePersistentProperty>) persistentProperty -> {
|
||||
persistentProperty.findAnnotation(Id.class).ifPresent(idAnnotation ->
|
||||
registerIndexBeanDefinition(enableIndexesAttributes, localPersistentEntity, persistentProperty,
|
||||
registerIndexBeanDefinition(enableIndexingAttributes, localPersistentEntity, persistentProperty,
|
||||
IndexType.KEY, idAnnotation, registry));
|
||||
|
||||
persistentProperty.findAnnotation(Indexed.class).ifPresent(indexedAnnotation ->
|
||||
registerIndexBeanDefinition(enableIndexesAttributes, localPersistentEntity, persistentProperty,
|
||||
registerIndexBeanDefinition(enableIndexingAttributes, localPersistentEntity, persistentProperty,
|
||||
indexedAnnotation.type(), indexedAnnotation, registry));
|
||||
|
||||
persistentProperty.findAnnotation(LuceneIndexed.class).ifPresent( luceneIndexAnnotation ->
|
||||
registerLuceneIndexBeanDefinition(enableIndexesAttributes, localPersistentEntity,
|
||||
registerLuceneIndexBeanDefinition(enableIndexingAttributes, localPersistentEntity,
|
||||
persistentProperty, luceneIndexAnnotation, registry));
|
||||
});
|
||||
}
|
||||
@@ -142,8 +142,8 @@ public class IndexConfiguration extends EntityDefinedRegionsConfiguration {
|
||||
* Registers an Index of the given {@link IndexType} for the {@link GemfirePersistentProperty}
|
||||
* on the {@link GemfirePersistentEntity} using the {@link Annotation} meta-data to define the Index.
|
||||
*
|
||||
* @param enableIndexesAttributes {@link AnnotationAttributes} containing meta-data
|
||||
* for the {@link EnableIndexes} annotation.
|
||||
* @param enableIndexingAttributes {@link AnnotationAttributes} containing meta-data
|
||||
* for the {@link EnableIndexing} annotation.
|
||||
* @param persistentEntity {@link GemfirePersistentEntity} containing the {@link GemfirePersistentProperty}
|
||||
* to be indexed.
|
||||
* @param persistentProperty {@link GemfirePersistentProperty} for which the Index will be created.
|
||||
@@ -157,7 +157,7 @@ public class IndexConfiguration extends EntityDefinedRegionsConfiguration {
|
||||
* @see org.springframework.data.gemfire.mapping.GemfirePersistentEntity
|
||||
* @see org.springframework.data.gemfire.mapping.GemfirePersistentProperty
|
||||
*/
|
||||
protected void registerIndexBeanDefinition(AnnotationAttributes enableIndexesAttributes,
|
||||
protected void registerIndexBeanDefinition(AnnotationAttributes enableIndexingAttributes,
|
||||
GemfirePersistentEntity<?> persistentEntity, GemfirePersistentProperty persistentProperty,
|
||||
IndexType indexType, Annotation indexAnnotation, BeanDefinitionRegistry registry) {
|
||||
|
||||
@@ -171,7 +171,7 @@ public class IndexConfiguration extends EntityDefinedRegionsConfiguration {
|
||||
|
||||
indexFactoryBeanBuilder.addPropertyReference("cache", GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME);
|
||||
|
||||
indexFactoryBeanBuilder.addPropertyValue("define", resolveDefine(enableIndexesAttributes));
|
||||
indexFactoryBeanBuilder.addPropertyValue("define", resolveDefine(enableIndexingAttributes));
|
||||
|
||||
indexFactoryBeanBuilder.addPropertyValue("expression",
|
||||
resolveExpression(persistentEntity, persistentProperty, indexedAttributes));
|
||||
@@ -195,8 +195,8 @@ public class IndexConfiguration extends EntityDefinedRegionsConfiguration {
|
||||
* Registers a {@link LuceneIndex} for the {@link GemfirePersistentProperty} on the {@link GemfirePersistentEntity}
|
||||
* using the {@link Annotation} meta-data to define the Index.
|
||||
*
|
||||
* @param enableIndexesAttributes {@link AnnotationAttributes} containing meta-data
|
||||
* for the {@link EnableIndexes} annotation.
|
||||
* @param enableIndexingAttributes {@link AnnotationAttributes} containing meta-data
|
||||
* for the {@link EnableIndexing} annotation.
|
||||
* @param persistentEntity {@link GemfirePersistentEntity} containing the {@link GemfirePersistentProperty}
|
||||
* to be indexed.
|
||||
* @param persistentProperty {@link GemfirePersistentProperty} for which the {@link LuceneIndex} will be created.
|
||||
@@ -210,7 +210,7 @@ public class IndexConfiguration extends EntityDefinedRegionsConfiguration {
|
||||
* @see org.springframework.data.gemfire.mapping.annotation.LuceneIndexed
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
protected void registerLuceneIndexBeanDefinition(AnnotationAttributes enableIndexesAttributes,
|
||||
protected void registerLuceneIndexBeanDefinition(AnnotationAttributes enableIndexingAttributes,
|
||||
GemfirePersistentEntity<?> persistentEntity, GemfirePersistentProperty persistentProperty,
|
||||
Annotation luceneIndexAnnotation, BeanDefinitionRegistry registry) {
|
||||
|
||||
@@ -239,9 +239,9 @@ public class IndexConfiguration extends EntityDefinedRegionsConfiguration {
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
private boolean resolveDefine(AnnotationAttributes enableIndexesAnnotationAttributes) {
|
||||
return (enableIndexesAnnotationAttributes.containsKey("define")
|
||||
&& enableIndexesAnnotationAttributes.getBoolean("define"));
|
||||
private boolean resolveDefine(AnnotationAttributes enableIndexingAttributes) {
|
||||
return (enableIndexingAttributes.containsKey("define")
|
||||
&& enableIndexingAttributes.getBoolean("define"));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
|
||||
Reference in New Issue
Block a user