Reputation: 50362
I would like to make some request-wide data available in my app engine application.
Examples:
I see that ThreadLocal
is on GAE's JRE whitelist.
Is ThreadLocal
a good and safe way to make this information available? Are there alternative / better / more accepted ways?
Upvotes: 5
Views: 1352
Reputation: 597124
Yes, it is an accepted practice to store these things in a ThreadLocal
. However, a more preferable approach is to pass these values around (as method arguments) wherever they are needed, instead of reaching for them. It's more preferable, because it's more testable at least.
Upvotes: 8