Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Renamed
Wiki Markup
{scrollbar}

Symbols

Tapestry IOC makes use of runtime-evaluated symbols to handle certain types of configuration tasks.

...

Although not shown here, it is possible to use multiple symbols inside the string, or mix literal text with symbols.

Injecting Values from Symbols

You may also inject symbol values. For example, if you are interested in whether the application is in production mode or developer mode:

Code Block
java
java
public class MyService implements MyServiceInterface
{
  private boolean productionMode;

  public MyService(@Value("${tapestry.production-mode}") boolean productionMode, ...)
  {
    this.productionMode = productionMode;
    . . .

Here Tapestry has coerced the "tapestry.production-mode" symbol to a boolean to be injected.

...

Note: When injecting a symbol as a string into a service, you must use the @Inject annotation as well as @Value or @Symbol; otherwise Tapestry will inject the service's service id.

Symbol Resolution

Symbols are resolved by the SymbolSource service. The SymbolSource checks against an ordered list of SymbolProvider objects.

...

By default, there are three providers:

SystemProperties

The first provider allows JVM System Properties to provide symbol values. This allows the use of the java command's -D option to provide runtime overrides. This is most often used when testing code, rather than in production. SystemProperties is always checked first.

ApplicationDefaults

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.

...

Code Block
java
java
  public void contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
  {
    configuration.add("some-service-id", "WackyCollaborator");
  }

FactoryDefaults

The same as ApplicationDefaults, but checked only if a value is not satisfied by SystemProperties or ApplicationDefaults.

...

FactoryDefaults is always checked last when resolving symbol names to symbol values.

Recursive Symbols

It is possible and valid to define one symbol in terms of one ore more other symbols.

...