Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-16971

Scoped data container

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: Waiting for Triage
    • Component/s: Core:DI
    • Labels:
    • Last commented by a User:
      true

      Description

      My suggestion would be some kind of a generic data container, whose scope can be parameterized. There could be some annotation, let's say

      @ScopedContainer(scope = "some_scope")
      

      that can be applied to fields, or setter methods.

      A typical use-case would be, when I want to store some data in a bean of scope singleton, but I need the data List<String> to be session scoped. I could then write a code:

      @Component
      public class MySingletonBean {
      
          @ScopedContainer(scope="session")
          private List<String> dataForSession;
      
          public List<String> getStrings() {
              return dataForSession;
          }
          ...
      }
      

      A work around for this feature is creating a generic bean for every scope and using proxy to inject, but I think we could all at some point make use of some feature like this.

        Attachments

          Activity

            People

            Assignee:
            juergen.hoeller Juergen Hoeller
            Reporter:
            rolaca11 László Stahorszki
            Last updater:
            Spring Issues Spring Issues
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Days since last comment:
              3 years, 30 weeks, 5 days ago