gemfirespring-data-gemfire

How to add ComponentScan.Filter in @EnableEntityDefinedRegion


When I added an includeFilter to @EnableEntityDefinedRegion, it still scanned the whole entity package and created all Region beans. How do I scan the specific Region class? For example, only "Address" Region.

package org.test.entity
@Getter
@Setter
@Region("Address")
public class GfAddress implements Serializable

package org.test.entity
@Getter
@Setter
@Region("CreditCard")
public class GfCreditCard implements Serializable

package org.test.package
public interface IAddressRepository extends GemfireRepository<GfAddress, String>

package org.test.package
public interface ICreditCardRepository extends GemfireRepository<GfCreditCard , String>

@Service
@ClientCacheApplication
@EnableGemfireRepositories(basePackages = IAddressRepository.class, includeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes=AddressRepository.class))
@EnableEntityDefinedRegion(basePackages = GfAddress.class, includeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern="GfAddress*"))
public class AddressDataAccess

When I print all the beans that are loaded, I found out that the following beans are created.

  1. Address
  2. CreditCard
  3. IAddressRepository
  4. AddressDataAccess

Version

  1. GemFire : 9.8.6
  2. spring-data-gemfire : 2.1.0
  3. Spring Boot : 2.1.0

Solution

  • Sorry for the delay.

    First, have a look at the SDG JIRA ticket I filed, DATAGEODE-352 - "EnableEntityDefinedRegions.includeFilters are inappropriately overridden by framework provided include filters".

    In this ticket, I describe a couple of workarounds to this bug (!) in the comments, starting here.

    I'd also be careful about your REGEX. I am no Regular Expression expert, but I am certain "GfAddress*" will not properly match the application entity type you are searching for and trying to match even when you pick up the new SDG bits resolving the issue I filed.

    I created a similar test, using REGEX, to verify the resolution of the issue, here. This is the REGEX I specified. Using "Programmer*" did not work, as I suspected! That is because the REGEX is not valid and does not match the FQCN as used in the Spring RegexPatternTypeFilter.

    Technically, it would be better to be a bit more specific about your type matching and use a "ASSIGNABLE_TYPE" TypeFilter instead, as this test demonstrates.

    Finally, while SDG 2.1.x is compatible with GemFire 9.8.x, SD[G] Lovelace, or 2.1.x (e.g. 2.1.18.RELEASE), is officially based on, and only "supports", VMware GemFire 9.5.x (currently 9.5.4).

    SDG 2.2.x is officially based on, and "supports", VMware GemFire 9.8.x (currently at 9.8.8).

    You can review the new SDG Version Compatibility Matrix for more details.

    If you have more questions, please follow up here or in DATAGEODE-352.