As an Spring [Boot] application developer developing Spring applications using Apache Geode or VMware GemFire, and I declare and use the @EnableEntityDefinedRegions annotation in my Spring application @Configuration class to create GemFire/Geode Regions from application entity classes, then I expect the includeFilters to limit entity classes discovered in the scan when identifying GemFire/Geode Regions to create.
Currently, all Regions defined by application entities in the declared application entity class packages are created because the SDG framework include filters are overriding the user-defined includeFilters.
Keep in mind, the includeFilters, as implied in the Spring Framework @ComponentScan annotation, includeFilters attribute, are combined using the logical OR operator. Additionally, includeFilters can cancel the effect of 1 or more excludeFilters. So be mindful when using these 2 attributes in conjunction with each other.
The SDG framework provides @Region annotated (and variants) AnnotationTypeFilters for all the @Region like mapping annotations (see here). If an application entity class matches 1 of the user-defined includeFilters or 1 of the SDG framework @.*RegionAnnotationTypeFilters during the scan then the entity class is included and the declared Region will be created.
While application entity classes should and must include an @.*Region mapping annotation to be included in the scan, this should not be either "OR". Rather, the includeFilters defined by a user should be ANDed with the framework includeFilters
If you only want a single Region created from an application entity class (out of of many), then rather than target the Region specifically with Regex, you can use an explicit Region bean definition, like so:
Given an entity class:
@Region("Example")
classExample { ... }
Then, define the "Example" Region with an explicit Region bean definition:
Alternatively, you could use a BeanFactoryPostProcessor to post-process the Spring Container BeanDefinitions, or a Spring BeanPostProcessor to post-process the bean (instance) either before or after initialization.
John Blum opened DATAGEODE-352 and commented
As an Spring [Boot] application developer developing Spring applications using Apache Geode or VMware GemFire, and I declare and use the
@EnableEntityDefinedRegions
annotation in my Spring application@Configuration
class to create GemFire/Geode Regions from application entity classes, then I expect theincludeFilters
to limit entity classes discovered in the scan when identifying GemFire/Geode Regions to create.Currently, all Regions defined by application entities in the declared application entity class packages are created because the SDG framework include filters are overriding the user-defined
includeFilters
.Keep in mind, the
includeFilters
, as implied in the Spring Framework@ComponentScan
annotation,includeFilters
attribute, are combined using the logical OR operator. Additionally,includeFilters
can cancel the effect of 1 or moreexcludeFilters
. So be mindful when using these 2 attributes in conjunction with each other.The SDG framework provides
@Region
annotated (and variants)AnnotationTypeFilters
for all the@Region
like mapping annotations (see here). If an application entity class matches 1 of the user-definedincludeFilters
or 1 of the SDG framework@.*Region
AnnotationTypeFilters
during the scan then the entity class is included and the declared Region will be created.While application entity classes should and must include an
@.*Region
mapping annotation to be included in the scan, this should not be either "OR". Rather, theincludeFilters
defined by a user should be ANDed with the frameworkincludeFilters
Reference URL: https://stackoverflow.com/questions/62445958/how-to-add-componentscan-filter-in-enableentitydefinedregion
Backported to: 2.3.2 (Neumann SR2), 2.2.9 (Moore SR9), 2.1.19 (Lovelace SR19)
The text was updated successfully, but these errors were encountered: