Package edu.uiuc.ncsa.security.util
Class XXProperties
- java.lang.Object
-
- java.util.Dictionary<K,V>
-
- java.util.Hashtable<Object,Object>
-
- java.util.Properties
-
- edu.uiuc.ncsa.security.core.configuration.XProperties
-
- edu.uiuc.ncsa.security.util.XXProperties
-
- All Implemented Interfaces:
Serializable,Cloneable,Map<Object,Object>
public class XXProperties extends XProperties
This extension of XProperties allows for loading XProperties with template resolution by flag -- use system and JVM properties or by supplying a template file. Each line is read and processed with the template, so you can have expressions line${db.type}_${USER}=${NCSA_DEV_INPUT}/scripts/database.sh -u ${db.logon}and have the user name used as part of the property name. Note that in this example, the uppercase properties are from the OS, the lower case one is (assumed to be) a Java property passed to the JVM. this might resolve to the property namedmysql_jeffwith the value/home/ncsa/dev/scripts/database.sh -u oa4mp-user42Created by Jeff Gaynor
on 8/22/23 at 9:41 AM- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class edu.uiuc.ncsa.security.core.configuration.XProperties
DEFAULT_LIST_SEPARATOR, LOGICAL_FALSES, LOGICAL_TRUES, storeFileName
-
Fields inherited from class java.util.Properties
defaults
-
-
Constructor Summary
Constructors Constructor Description XXProperties()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,String>getAllProperties()AMapof all the OS and java properties for use resolving configuration testing files.Map<String,String>getAllProperties(boolean reload)Force a reload of system properties.voidload(File file, boolean useSystemProperties)voidload(File file, Map templates)voidload(InputStream inputStream, boolean useSystemProperties)voidload(InputStream inputStream, Map templates)voidload(Reader reader, Map templates)Actual work method for this entire classvoidload(String fileName, boolean useSystemProperties)If true, use the system and environment properties for loading.voidload(String fileName, Map templates)voidloadResource(String resourceName, boolean useSystemProperties)voidloadResource(String resourceName, Map templates)Resolves the name as a resource in the local class loader, rather than as a file on the system.static voidmain(String[] args)-
Methods inherited from class edu.uiuc.ncsa.security.core.configuration.XProperties
add, add, add, clone, equals, getArrayList, getArrayList, getBoolean, getBytes, getClone, getDate, getDouble, getFile, getFile, getInt, getList, getList, getListSeparator, getLong, getSerializable, getSerializableList, getStoreFileName, getString, getURI, getURL, isEmpty, isList, isList, keySubset, load, load, load, setBoolean, setBytes, setDate, setDouble, setFile, setInt, setList, setList, setList, setListSeparator, setLong, setProperty, setSerializable, setSerializableList, setStoreFileName, setString, setURI, setURI, setURL, setURL, store, store, toString
-
Methods inherited from class java.util.Properties
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, forEach, get, getOrDefault, getProperty, getProperty, hashCode, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
-
-
-
Method Detail
-
load
public void load(String fileName, boolean useSystemProperties) throws IOException
If true, use the system and environment properties for loading.- Parameters:
fileName-useSystemProperties- use system and environment properties as templates- Throws:
IOException
-
load
public void load(String fileName, Map templates) throws IOException
- Throws:
IOException
-
load
public void load(File file, boolean useSystemProperties) throws IOException
- Parameters:
file-useSystemProperties- use system and environment properties as templates- Throws:
IOException
-
load
public void load(File file, Map templates) throws IOException
- Throws:
IOException
-
load
public void load(InputStream inputStream, boolean useSystemProperties) throws IOException
- Parameters:
inputStream-useSystemProperties- use system and environment properties as templates- Throws:
IOException
-
load
public void load(InputStream inputStream, Map templates) throws IOException
- Throws:
IOException
-
load
public void load(Reader reader, Map templates) throws IOException
Actual work method for this entire class- Parameters:
reader-templates-- Throws:
IOException
-
loadResource
public void loadResource(String resourceName, Map templates) throws IOException
Resolves the name as a resource in the local class loader, rather than as a file on the system.- Parameters:
resourceName-templates-- Throws:
IOException
-
loadResource
public void loadResource(String resourceName, boolean useSystemProperties) throws IOException
- Parameters:
resourceName-useSystemProperties- use system and environment properties as templates- Throws:
IOException
-
getAllProperties
public Map<String,String> getAllProperties()
AMapof all the OS and java properties for use resolving configuration testing files. Java properties override OS properties. Typically given to the JVM at startup with a -D prefix, so to set the property named my.prop at startup for the application MyApp you'd writejava -Dmy.prop="my-value" MyAppNote that this is pretty expensive so will be done only when called then stored, so you cannot update the properties on the fly. For that consider usinggetAllProperties(boolean).- Returns:
-
getAllProperties
public Map<String,String> getAllProperties(boolean reload)
Force a reload of system properties.- Parameters:
reload- if true, properties are reloaded at each call. If false, they are cached.- Returns:
-
main
public static void main(String[] args)
-
-