Dashboard > QuickFIX/J > ... > Articles > Using Variables in Settings Files
QuickFIX/J Log In | Sign Up   View a printable version of the current page.
Using Variables in Settings Files
Added by Steve Bate, last edited by Steve Bate on Jan 09, 2007
Labels: 
(None)

The quickfix.SessionSettings class supports variable interpolation using a configured set of substitution values. By default, the substitution values are JVM system properties.

The variable syntax is "${variable}". For example, if system property "user.name" is "USER"...

FileStorePath=logs/${user.name}

becomes...

FileStorePath=logs/USER

Remember that system properties can be specified to the JVM using the -D argument on the command line. You can also use the method SessionSettings.setVariableValues() to configure your own set of substitution values.

Properties settingsVariableValues= new Properties();
settingsVariableValues.put("myvariable", "somevalue");
... other custom settings

settings.setVariableValues(settingsVariableValues);

The substitution values could be loaded from a property file.

Properties myCustomSettingsVariables = new Properties();
myCustomSettingsVariables.load(inputStream);
settings.setVariableValueS(myCustomSettingsVariables);

You can implement simple property inheritance by constructing a chain of java.util.Properties objects.

Properties settingsVariableValues= new Properties(System.getProperties());
settingsVariableValues.put("myvariable", "somevalue");
... other custom settings, possibly overriding the default system properties

These techniques give you a simple way to create templates of settings files that are customized based on run time values.

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.1.5a Build:#411 Mar 16, 2006) - Bug/feature request - Contact Administrators

SourceForge.net Logo