You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by bu...@apache.org on 2016/04/03 01:19:42 UTC
svn commit: r984560 - in /websites/production/tapestry/content:
cache/main.pageCache symbols.html
Author: buildbot
Date: Sat Apr 2 23:19:42 2016
New Revision: 984560
Log:
Production update by buildbot for tapestry
Modified:
websites/production/tapestry/content/cache/main.pageCache
websites/production/tapestry/content/symbols.html
Modified: websites/production/tapestry/content/cache/main.pageCache
==============================================================================
Binary files - no diff available.
Modified: websites/production/tapestry/content/symbols.html
==============================================================================
--- websites/production/tapestry/content/symbols.html (original)
+++ websites/production/tapestry/content/symbols.html Sat Apr 2 23:19:42 2016
@@ -158,7 +158,21 @@
if (productionMode) {
. . .
</pre>
-</div></div><p>This is very useful when a constant value is defined for the symbol; it means that the compiler can catch a typo, rather than detecting it a runtime.</p><p><strong>Note:</strong> When injecting a symbol as a <em>string</em> into a service, you must use the @Inject annotation as well as @Value or @Symbol; otherwise Tapestry will inject the service's service id.</p><h2 id="Symbols-SymbolResolution">Symbol Resolution</h2><p>Symbols are resolved by the <a class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/services/SymbolSource.html">SymbolSource</a> service. The SymbolSource service checks against an ordered list of <a class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/services/SymbolProvider.html">SymbolProvider</a> objects.</p><p>You may employ additional symbol providers by contributing to the SymbolSource service configuration, which is an ordered list of SymbolProviders.</p><p
>By default, there are three providers:</p><h3 id="Symbols-SystemPropertiesProvider">SystemProperties Provider</h3><p>The first provider allows JVM System Properties to provide symbol values. This allows the use of the <strong>java</strong> command's <strong>-D</strong> option to provide runtime overrides. This is most often used when testing code, rather than in production. SystemProperties is always checked first.</p><h3 id="Symbols-ApplicationDefaultsProvider">ApplicationDefaults Provider</h3><p>Values not found as System Properties are searched for in the ApplicationDefaults. This service, ApplicationDefaults, may be configured using a mapped configuration to provide values.</p><p>From the previous example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>This is very useful when a constant value is defined for the symbol; it means that the compiler can catch a typo, rather than detecting it a runtime.</p><p><strong>Note:</strong> When injecting a symbol as a <em>string</em> into a service, you must use the @Inject annotation as well as @Value or @Symbol; otherwise Tapestry will inject the service's service id.</p><h2 id="Symbols-SymbolsinComponentClassesandTemplates">Symbols in Component Classes and Templates</h2><p>It's easy to use a symbol in a component class:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> @Inject
+ @Symbol(SymbolConstants.PRODUCTION_MODE)
+ private boolean productionMode;
+ . . .
+ void setupRender() {
+ if (productionMode) {
+ . . .
+ }
+ }</pre>
+</div></div><p>You can even use them directly in a component template, using the "symbol" binding prefix:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><t:if test="!symbol:tapestry.production-mode">
+ <p>WARNING: We're running in development mode (slower, and less secure)</p>
+</t:if></pre>
+</div></div><h2 id="Symbols-SymbolResolution">Symbol Resolution</h2><p>Symbols are resolved by the <a class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/services/SymbolSource.html">SymbolSource</a> service. The SymbolSource service checks against an ordered list of <a class="external-link" href="http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/services/SymbolProvider.html">SymbolProvider</a> objects.</p><p>You may employ additional symbol providers by contributing to the SymbolSource service configuration, which is an ordered list of SymbolProviders.</p><p>By default, there are three providers:</p><h3 id="Symbols-SystemPropertiesProvider">SystemProperties Provider</h3><p>The first provider allows JVM System Properties to provide symbol values. This allows the use of the <strong>java</strong> command's <strong>-D</strong> option to provide runtime overrides. This is most often used when testing code, rather than in pro
duction. SystemProperties is always checked first.</p><h3 id="Symbols-ApplicationDefaultsProvider">ApplicationDefaults Provider</h3><p>Values not found as System Properties are searched for in the ApplicationDefaults. This service, ApplicationDefaults, may be configured using a mapped configuration to provide values.</p><p>From the previous example:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> public void contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
{
configuration.add("some-service-id", "WackyCollaborator");