System Default Config

Each JVM has a system default config. This is a configuration file that serves as the default configuration for the system. It's accessed using the following static methods:

- {@link oaj.config.Config}
  - {@link oaj.config.Config#getSystemDefault() getSystemDefault()}
  - {@link oaj.config.Config#setSystemDefault(Config) setSystemDefault(Config)}

If you do not specify a system default config, one will be automatically searched for. The search is done in the following order:

1. If the system property "juneau.configFile" is set, we search for this file in first the home directory and then the classpath.
2. In the home directory:
   1. <jar-name>.cfg
   2. Any file that end with .cfg. First one matched alphabetically is used.
3. In the context classpath root package (i.e. inside the jar itself):
   1. <jar-name>.cfg
   2. juneau.cfg
   3. default.cfg
   4. application.cfg
   5. app.cfg
   6. settings.cfg
   7. application.properties

Later in the section on REST resources, we describe how to associate configurations with REST resources using the {@link oajr.annotation.Rest#config() @Rest(config)} annotation. The system default configuration can be referenced with the keyword SYSTEM_DEFAULT like so:

// Always use system default. @Rest(config="SYSTEM_DEFAULT") // Use system property if set or the system default if not. @Rest(config="$S{juneau.configFile,SYSTEM_DEFAULT}")

By default, all properties in the system default configuration are automatically set as system properties. This can be disabled by setting the system property "juneau.disableAutoSystemProps" to "true".