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

Repeatable @Scope

    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:
      None
    • Last commented by a User:
      true

      Description

      so one of the problems, I'm looking at with logging, is the idea, that a request doesn't imply a transaction, and a transaction doesn't imply a request. I'd like to have my scope eagerly instantiated if either begins, the ideally they would share that bean until the last scope ended. That might be hard though... might be easier to create a different bean for each scope.

         @Bean
          @Scope("transaction")
          @Scope("request")
          static CloseableThreadContext.Instance requestContext(
              @Value( "${dex.environment}" ) String env,
              String hostname
          )
          {// spring will close
              CloseableThreadContext.Instance ctx = CloseableThreadContext.put( "env", env );
              ctx.put( "hostname", hostname );
              return ctx;
          }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              xenoterracide Caleb Cushing
              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, 29 weeks, 6 days ago