Package com.xceptance.xlt.api.util
Class XltProperties
- java.lang.Object
-
- com.xceptance.xlt.api.util.XltProperties
-
public abstract class XltProperties extends java.lang.ObjectThe property keeper. Loads and stores the properties of the entire tool. Single instance implementation.The process of looking up a property uses multiple fall-backs. When resolving the value for the key "foo.bar", for instance, the following effective keys are tried, in this order:
- the test user name plus simple key, e.g. "TOrder.foo.bar"
- the test class name plus simple key, e.g. "posters.loadtest.tests.TOrder.foo.bar"
- the simple key, i.e. "foo.bar"
-
-
Constructor Summary
Constructors Constructor Description XltProperties()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description abstract booleancontainsKey(java.lang.String key)Checks whether there is a mapping for the specified key in this property list.static XltPropertiesgetInstance()Returns the one and only XltProperties instance.abstract java.util.PropertiesgetProperties()Returns a copy of all the internally stored properties, with any placeholder resolved.abstract java.util.Map<java.lang.String,java.lang.String>getPropertiesForKey(java.lang.String domainKey)Returns all properties whose name starts with the given domain key.abstract java.lang.StringgetProperty(java.lang.String key)Searches for the property with the specified key in this property list.abstract booleangetProperty(java.lang.String key, boolean defaultValue)Searches for the property with the specified key in this property list.abstract intgetProperty(java.lang.String key, int defaultValue)Searches for the property with the specified key in this property list.abstract longgetProperty(java.lang.String key, long defaultValue)Searches for the property with the specified key in this property list.abstract java.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)Searches for the property with the specified key in this property list.abstract java.lang.StringgetPropertyRandomValue(java.lang.String key, java.lang.String defaultValue)Returns one value of the given multi-value property.abstract java.util.List<java.lang.String>getResolvedPropertyFiles()Deprecated.For internal use only.abstract longgetStartTime()Returns the start time of the test in milliseconds since 1970.abstract java.lang.StringgetVersion()Returns the product version.abstract voidremoveProperty(java.lang.String key)Removes the property with the given key from the internal properties store.static voidreset()Deprecated.For internal use only.abstract voidsetProperties(java.io.File file)Defines a source for property data.abstract voidsetProperties(java.util.Properties newProperties)Method for changing the properties during runtime.abstract voidsetProperties(org.apache.commons.vfs2.FileObject file)Defines a source for property data.abstract voidsetProperty(java.lang.String key, java.lang.String value)Sets a property during runtime.abstract voidupdate()Updates the properties.
-
-
-
Method Detail
-
getInstance
public static XltProperties getInstance()
Returns the one and only XltProperties instance.- Returns:
- the XltProperties singleton
-
reset
@Deprecated public static void reset()
Deprecated.For internal use only.Resets the properties framework. This is mainly needed for testing.
-
containsKey
public abstract boolean containsKey(java.lang.String key)
Checks whether there is a mapping for the specified key in this property list.- Parameters:
key- the property key- Returns:
trueif there is a mapping,falseotherwise
-
getProperties
public abstract java.util.Properties getProperties()
Returns a copy of all the internally stored properties, with any placeholder resolved.- Returns:
- the properties
-
getPropertiesForKey
public abstract java.util.Map<java.lang.String,java.lang.String> getPropertiesForKey(java.lang.String domainKey)
Returns all properties whose name starts with the given domain key. The domain is stripped from the resulting property names.- Parameters:
domainKey- domain for the properties- Returns:
- a map with all matching properties
-
getProperty
public abstract java.lang.String getProperty(java.lang.String key)
Searches for the property with the specified key in this property list. The method returns null if the property is not found.- Parameters:
key- the property key- Returns:
- the value of the key
-
getProperty
public abstract boolean getProperty(java.lang.String key, boolean defaultValue)Searches for the property with the specified key in this property list. The method returns the default value argument if the property is not found.- Parameters:
key- the property keydefaultValue- the defaultValue if key not found- Returns:
- the value of the key as a boolean
-
getProperty
public abstract int getProperty(java.lang.String key, int defaultValue)Searches for the property with the specified key in this property list. The method returns the default value argument if the property is not found.- Parameters:
key- the property keydefaultValue- the defaultValue if key not found- Returns:
- the value of the key as an int
-
getProperty
public abstract long getProperty(java.lang.String key, long defaultValue)Searches for the property with the specified key in this property list. The method returns the default value argument if the property is not found.- Parameters:
key- the property keydefaultValue- the defaultValue if key not found- Returns:
- the value of the key as a long
-
getProperty
public abstract java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)Searches for the property with the specified key in this property list. The method returns the default value argument if the property is not found. The key is upper-cased before the property will be searched.- Parameters:
key- the property keydefaultValue- the defaultValue if key not found- Returns:
- the value of the key
-
getPropertyRandomValue
public abstract java.lang.String getPropertyRandomValue(java.lang.String key, java.lang.String defaultValue)Returns one value of the given multi-value property. Multiple values are separated by comma, semicolon, or space. The returned value is chosen randomly from the set of values.- Parameters:
key- the name of the propertydefaultValue- the default property value (a multi-value)- Returns:
- one of the values, chosen randomly
-
getStartTime
public abstract long getStartTime()
Returns the start time of the test in milliseconds since 1970.- Returns:
- the start time of the test in milliseconds
-
getVersion
public abstract java.lang.String getVersion()
Returns the product version.- Returns:
- the version string, e.g. "1.1.0"
-
removeProperty
public abstract void removeProperty(java.lang.String key)
Removes the property with the given key from the internal properties store.- Parameters:
key- the property key
-
setProperties
public abstract void setProperties(java.io.File file) throws java.io.IOExceptionDefines a source for property data. If properties are already loaded, these new properties will be added. If a property already exists it will be overwritten. Last one wins. Automatically adds java system properties afterwards.- Parameters:
file- the file that contains the properties to be loaded- Throws:
java.io.IOException- thrown when opening the file or reading from the file failed
-
setProperties
public abstract void setProperties(org.apache.commons.vfs2.FileObject file) throws java.io.IOExceptionDefines a source for property data. If properties are already loaded, these new properties will be added. If a property already exists it will be overwritten. Last one wins. Automatically adds java system properties afterwards.- Parameters:
file- the file that contains the properties to be loaded- Throws:
java.io.IOException- thrown when opening the file or reading from the file failed
-
setProperties
public abstract void setProperties(java.util.Properties newProperties)
Method for changing the properties during runtime. Can be called multiple times to add additional properties. Automatically adds java system properties afterwards.- Parameters:
newProperties- complete new set of properties, will be added to existing properties and overwrites already defined properties with new values. None existing properties will be added.
-
setProperty
public abstract void setProperty(java.lang.String key, java.lang.String value)Sets a property during runtime. Overwrites an existing property with the same name. Does not re-apply any java system settings.- Parameters:
key- new property keyvalue- new property value
-
update
public abstract void update()
Updates the properties.
-
getResolvedPropertyFiles
@Deprecated public abstract java.util.List<java.lang.String> getResolvedPropertyFiles()
Deprecated.For internal use only.Returns the absolute paths to the resolved property files. This means the property files which are there by default and the property files transitively included by "includes" in these property files. However note that some of the default files are optional (as "dev.properties") and the returned list only contains existing files.- Returns:
- the resolved property files as described above
-
-