Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Won't Do
-
1.9.6 (Ingalls SR6), 2.0 RC2 (Kay)
Description
This is somewhat related to https://jira.spring.io/browse/SGF-261. I would like to be able to use the @Region("MyRegion") semantics on an entity and have it persist to a region whose name could be plugged in at runtime. For example my dev environment might persist to a region called 'MyRegion_dev' and QA might persist to 'MyRegion_QA' and those names would be programmatically set at application startup in a JavaConfig class.
The problem is that when you call getTemplate() on the GemfireRepositoryFactory, it looks at the Entity's and Repository's @Region("MyRegion") annotation and looks for an existing region called 'MyRegion.' There is currently no support for SPEL in the Region annotation. If 'MyRegion' doesn't exist, the app errors out and fails to start.
My proposed solution is to keep the existing logic as is - where based on the contents of the @Region("MyRegion") annotation, or the name of the entity class, it looks for a region called 'MyRegion,' but if it doesn't exist, check for a Spring bean of type Region with the bean name 'MyRegion.' and use that region to persist.
If this seems viable, I have a PR ready to go.