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

eager @Scoped beans

    XMLWordPrintable

    Details

    • Type: New Feature
    • 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

      I tried this, but including the autowired HttpServletRequest

          @Bean
          @RequestScope
          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;
          }
      

      was thinking that I could simply propagate the context with with it, I then tried adding @Lazy(false) to the definition, but it still didn't instantiate object until I fetched, and called a method on it.

      I would like a way to say @Eager on scoped beans (note: this example has @RequestScope but I was also trying to do it with a registered/known working SimpleTransactionScope and SimpleThreadScope

      I don't want that to be the default behavior for scoped beans, just an option to create them as soon as scope comes into being.

        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