...
@Environmental
is different; it exposes a request-scoped, dynamically bound value
Footnote |
---|
Wiki Markup |
{footnote}. The term . The term "Environmental" was chosen as the value "comes from the environment", whatever that means. A name more evocative of its function still has not occurred to the Tapestry team!{footnote} |
- Request scoped: different threads (processing different requests) will see different values when reading the field.
- Dynamically bound: the value is explicitly placed into the Environment, and can be overridden at any time.
...
In certain cases, Tapestry exposes a service (which can be injected) that is a proxy to the environmental; this is primarily for common environmentals, such as JavaScriptSupport, that may be needed outside of component classes. You can see this in TapestryModule:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
/** * Builds a proxy to the current {@link JavaScriptSupport} inside this thread's {@link Environment}. * * @since 5.2.0 */ public JavaScriptSupport buildJavaScriptSupport() { return environmentalBuilder.build(JavaScriptSupport.class); } |
...
Yes, of course Tapestry is thread safe. The Request service is another special case, as seen in TapestryModule:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public Request buildRequest() { return shadowBuilder.build(requestGlobals, "request", Request.class); } |
...
Also remember that @Inject
on fields works for components and for service implementations or other objects that Tapestry instantiates, but not on arbitrary objects (that are created via Java's new keyword).
Wiki Markup |
---|
{scrollbar} |
...
Wiki Markup |
---|
{display-footnotes} |