Caleb Cushing opened SPR-17157 and commented
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.
Issue Links:
- #21695 Repeatable @Scope
Comment From: snicoll
I am going to close this for the same reason expressed in https://github.com/spring-projects/spring-framework/issues/21695#issuecomment-1727659683