Package org.ow2.clif.util
Class ConfigFileManager
- java.lang.Object
-
- org.ow2.clif.util.ConfigFileManager
-
public class ConfigFileManager extends java.lang.ObjectHelper class for managing the CLIF configuration file (typically named clif.opts) with regard to network-related properties:- fractal.registry.host and fractal.registry.port give the network address of the CLIF/Fractal registry, where all CLIF servers register. When not specified, the default host is localhost and the default port is 1234
- clif.codeserver.host and clif.codeserver.port give the network address of the CLIF coder server, that serves all classes and necessary resource files during test plan deployment. When not specified, the default host is localhost and the default port is 1357
- jonathan.connectionfactory.host is the IP address to be chosen among local configured network interfaces to be published in the registry. For a CLIF server, this IP address must be reachable from the deployment point (console, command-line deployment). For a deployment point, this IP address must be reachable by all CLIF servers. This property is automatically handled accordingly to the other network settings, using a smart configuration protocol requiring the registry to be running.
- clif.filestorage.host is the IP address to be chosen among local configured network interfaces of a CLIF server, to be given to the deployment point and used during the data collection phase. This IP address must be reachable from the deployment point. This property is automatically handled in the same way as the previous property.
load(boolean)method may be used to load the configuration file. Thestore()method shall be called to write the properties changes to the file.- Author:
- Bruno Dillenseger
-
-
Constructor Summary
Constructors Constructor Description ConfigFileManager(java.io.File conf)Creates a new configuration file manager associated to a given file object.ConfigFileManager(java.lang.String path)Creates a new configuration file manager to a given path name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringclearProperty(java.lang.String key)Discards a property.java.util.List<java.lang.String>getOptions()Get all the optionsjava.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)Get a property's value.voidload(boolean justTry)Loads a configuration file.static voidmain(java.lang.String[] args)Generates or modifies a CLIF configuration file, setting network-related properties.java.lang.StringsetProperty(java.lang.String key, java.lang.String value)Set a property's value.voidstore()Writes the properties to the configuration file.
-
-
-
Constructor Detail
-
ConfigFileManager
public ConfigFileManager(java.io.File conf)
Creates a new configuration file manager associated to a given file object.- Parameters:
conf- the file to manage
-
ConfigFileManager
public ConfigFileManager(java.lang.String path)
Creates a new configuration file manager to a given path name.- Parameters:
path- the path name to the configuration file
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.io.IOExceptionGenerates or modifies a CLIF configuration file, setting network-related properties.- Parameters:
args- configuration_file_path_name [registry_host[:registry_port]] [codeserver_host[:codeserver_port]]
With no optional argument, all network-related properties are discarded. The resulting CLIF configuration will work only on a single host.
With registry-only network arguments, registry-related properties are set as provided, and code server-related properties are set to the registry host and default code server port. In any case, the other network-related properties are automatically handled accordingly to the given parameters.- Throws:
java.io.IOException
-
load
public void load(boolean justTry) throws java.io.IOExceptionLoads a configuration file.- Parameters:
justTry- when false, an exception will be thrown when the file can't be loaded for any reason; when true, an exception will be thrown only when the configuration file exists but can't be loaded (either because of insufficient access rights, or because of I/O errors).- Throws:
java.io.IOException- the configuration file could not be read.
-
getProperty
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)Get a property's value.- Parameters:
key- the property namedefaultValue- the default value to return when the given property is not defined- Returns:
- the property's value, or the provided default value
-
getOptions
public java.util.List<java.lang.String> getOptions()
Get all the options- Returns:
- a list of option strings
-
setProperty
public java.lang.String setProperty(java.lang.String key, java.lang.String value)Set a property's value.- Parameters:
key- the property namevalue- the property value
-
clearProperty
public java.lang.String clearProperty(java.lang.String key)
Discards a property.- Parameters:
key- the property to discard- Returns:
- the property value just before the property was discarded, or null if this property was not defined.
-
store
public void store() throws java.io.IOExceptionWrites the properties to the configuration file.- Throws:
java.io.IOException- the configuration file could not be written
-
-