Class ThreadLocalSystemProperties
- java.lang.Object
-
- java.util.Dictionary<K,V>
-
- java.util.Hashtable<java.lang.Object,java.lang.Object>
-
- java.util.Properties
-
- com.wavemaker.commons.properties.ThreadLocalSystemProperties
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map<java.lang.Object,java.lang.Object>
public class ThreadLocalSystemProperties extends java.util.PropertiesSupport for storing System.setProperty calls in thread local. Mainly used to deal with third party libraries which sets new system properties and never clear them.To Enable usage of this class a single call to
enable()has to be done. To Disable usage of this class, a call todisable()need to be made. This needs to be done to remove all references for this class's classloader for smooth class unloading.Calling
record()before any such operation will store all calls toSystem.setProperty(String, String)in the current thread local only. Even for properties which are already defined in global level a new property is created in thread local Also calls toSystem.getProperty(String)will return values from current thread local and falls back to global vm level properties if not present in thread local.Calling
stop()will stop storing in thread local and any call toSystem.setProperty(String, String)will be store in global vm level properties for the current thread.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisable()Will only disable ThreadLocalProperties at the vm level Vm level properties previously set will still be presentThreadLocalSystemPropertiesenable()Will set ThreadLocalProperties as the default System properties at the vm level Existing System properties are still available by default at global level across all threadsjava.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>>entrySet()static voidexecuteInThreadLocalSystemProperties(java.lang.Runnable runnable)java.lang.StringgetProperty(java.lang.String key)java.lang.StringgetProperty(java.lang.String key, java.lang.String defaultValue)java.util.Set<java.lang.Object>keySet()voidlist(java.io.PrintStream out)voidlist(java.io.PrintWriter out)java.util.Enumeration<?>propertyNames()java.lang.ObjectsetProperty(java.lang.String key, java.lang.String value)intsize()java.util.Set<java.lang.String>stringPropertyNames()java.util.Set<java.lang.Object>values()-
Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, equals, forEach, get, getOrDefault, hashCode, isEmpty, keys, load, load, loadFromXML, merge, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, store, store, storeToXML, storeToXML, storeToXML, toString
-
-
-
-
Method Detail
-
enable
public ThreadLocalSystemProperties enable()
Will set ThreadLocalProperties as the default System properties at the vm level Existing System properties are still available by default at global level across all threads
-
disable
public void disable()
Will only disable ThreadLocalProperties at the vm level Vm level properties previously set will still be present
-
executeInThreadLocalSystemProperties
public static void executeInThreadLocalSystemProperties(java.lang.Runnable runnable)
-
getProperty
public java.lang.String getProperty(java.lang.String key)
- Overrides:
getPropertyin classjava.util.Properties
-
getProperty
public java.lang.String getProperty(java.lang.String key, java.lang.String defaultValue)- Overrides:
getPropertyin classjava.util.Properties
-
setProperty
public java.lang.Object setProperty(java.lang.String key, java.lang.String value)- Overrides:
setPropertyin classjava.util.Properties
-
propertyNames
public java.util.Enumeration<?> propertyNames()
- Overrides:
propertyNamesin classjava.util.Properties
-
stringPropertyNames
public java.util.Set<java.lang.String> stringPropertyNames()
- Overrides:
stringPropertyNamesin classjava.util.Properties
-
list
public void list(java.io.PrintStream out)
- Overrides:
listin classjava.util.Properties
-
list
public void list(java.io.PrintWriter out)
- Overrides:
listin classjava.util.Properties
-
keySet
public java.util.Set<java.lang.Object> keySet()
- Specified by:
keySetin interfacejava.util.Map<java.lang.Object,java.lang.Object>- Overrides:
keySetin classjava.util.Properties
-
values
public java.util.Set<java.lang.Object> values()
- Specified by:
valuesin interfacejava.util.Map<java.lang.Object,java.lang.Object>- Overrides:
valuesin classjava.util.Properties
-
size
public int size()
- Specified by:
sizein interfacejava.util.Map<java.lang.Object,java.lang.Object>- Overrides:
sizein classjava.util.Properties
-
entrySet
public java.util.Set<java.util.Map.Entry<java.lang.Object,java.lang.Object>> entrySet()
- Specified by:
entrySetin interfacejava.util.Map<java.lang.Object,java.lang.Object>- Overrides:
entrySetin classjava.util.Properties
-
-