Uploaded image for project: 'Spring Data GemFire'
  1. Spring Data GemFire
  2. SGF-659

Allow @Region annotations to refer to a Spring bean

    XMLWordPrintable

    Details

      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.

        Attachments

          Activity

            People

            Assignee:
            jblum John Blum
            Reporter:
            robhardt Rob Hardt
            Last updater:
            John Blum John Blum
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: