Configuration identifiers, key prefixes, and defaults
Configuration keys are literals, such as toolUrlPrefix
and baseUrl
. All configuration keys are isolated into prefixes that group the keys into similar functions. (In this way, the prefixes serve as namespaces.) The prefixes have the form of a directory path.
Referring to the previous illustration, the prefix is brightspot/
, and the configuration key is toolUrlPrefix
.
Some Brightspot features support multiple configurations, such as outgoing mail servers, file servers, and image editors. You place each configuration in its own prefix.
<Environment name="dari/mailProvider/normalServer/host" value="mail.example.com" />
<Environment name="dari/mailProvider/secureServer/host" value="secretagent.example.com" />
-
Configures a hostname for a standard mail server. The configuration ID is
normalServer
, and the entire prefix isdari/mailProvider/normalServer/
. -
Configures a hostname for a secured mail server. The configuration ID is
secureServer
, and the entire prefix isdari/mailProvider/secureServer/
.
Referring to the previous snippet, there are two configuration keys host, each with its own prefix.
For those features that support multiple configurations, you can assign one configuration as the default.
<Environment name="dari/defaultMailProvider" value="normalServer" />
<Environment name="dari/mailProvider/normalServer/host" value="mail.example.com" />
<Environment name="dari/mailProvider/secureServer/host" value="secretagent.example.com" />
-
Sets the default mail server configuration to the values with the prefix
dari/mailProvider/normalServer/
.
Providing a default configuration is useful because you can retrieve them with string constants in code.
public class MailProvider {
public static final String DEFAULT_MAIL_SETTING = "dari/defaultMailProvider";
public static final String SETTING_PREFIX = "dari/mailProvider";
}
Referring to the previous snippet, you can retrieve a setting using a combination of DEFAULT_MAIL_SETTING
and SETTING_PREFIX
. This strategy implies you can change the default configuration in Tomcat without making any changes in code and recompiling.