Configuration file specification and lookup
From JPPF 4.2 Documentation
Main Page > Configuration guide > Configuration file specification and lookup |
All JPPF components work with a set of configuration properties. The format of these properties is as specified in the Java Properties class. To enable a JPPF component to retrieve thiese properties file, their source must be specified using one of the two, mutually exclusive, system properties:
- jppf.config.plugin = class_name, where class_name is the fully qualified name of a class implementing the interface JPPFConfiguration.ConfigurationSource, or the interface JPPFConfiguration.ConfigurationSourceReader, enabling a configuration source from any origin, such as a URL, a distributed file system, a remote storage facility, a database, etc.
- jppf.config = path, where path is the location of the configuration file, either on the file system, or relative to the JVM's classpath root. If this system property is not specified, JPPF will look for a default file named "jppf.properties" in the current directory or in the classpath root.
Example use:
java -Djppf.config.plugin=my.own.Configuration ...
or
java -Djppf.config=my/folder/myFile.properties ...
The configuration file lookup mechanism is as follows:
- if jppf.plugin.config is specified
- a) instantiate an object of the specified class name and read the properties via the stream provided by this object's getPropertyStream() method.
- b) if, for any reason, the stream cannot be obtained or reading the properties from it fails, go to 3.
- else if jppf.config is specified
- a) look for the file in the file system
- b) if not found in the file system, look in the classpath
- c) if not found in the classpath use default configuration values
- if jppf.config is not specified
- a) use default file "jppf.properties"
- b) look for "jppf.properties" in the file system
- c) if not found in the file system, look for it in the classpath
- d) if not found in the classpath use default configuration values
A practical side effect of this mechanism is that it allows us to place a configuration file in the classpath, for instance packaged in a jar file, and override it if needed with an external file, since the the file system is always looked up first.
The JPPF configuration of a server, node or client is always programmatically accessible via the configuration API
Main Page > Configuration guide > Configuration file specification and lookup |