Package oshi.util
Class GlobalConfig
- java.lang.Object
-
- oshi.util.GlobalConfig
-
@NotThreadSafe public final class GlobalConfig extends java.lang.Object
The global configuration utility. Seesrc/main/resources/oshi.propertiesfor default values.This class is not thread safe if methods manipulating the configuration are used. These methods are intended for use by a single thread at startup, before instantiation of any other OSHI classes. OSHI does not guarantee re- reading of any configuration changes.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGlobalConfig.PropertyExceptionIndicates that a configuration value is invalid.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.PropertiesCONFIGstatic java.lang.StringOSHI_NETWORK_FILESYSTEM_TYPESstatic java.lang.StringOSHI_OS_LINUX_ALLOWUDEVstatic java.lang.StringOSHI_OS_LINUX_PROCFS_LOGWARNINGstatic java.lang.StringOSHI_OS_MAC_SYSCTL_LOGWARNINGstatic java.lang.StringOSHI_OS_SOLARIS_ALLOWKSTAT2static java.lang.StringOSHI_OS_UNIX_WHOCOMMANDstatic java.lang.StringOSHI_OS_WINDOWS_COMMANDLINE_BATCHstatic java.lang.StringOSHI_OS_WINDOWS_CPU_UTILITYstatic java.lang.StringOSHI_OS_WINDOWS_EVENTLOGstatic java.lang.StringOSHI_OS_WINDOWS_HKEYPERFDATAstatic java.lang.StringOSHI_OS_WINDOWS_LEGACY_SYSTEM_COUNTERSstatic java.lang.StringOSHI_OS_WINDOWS_LOADAVERAGEstatic java.lang.StringOSHI_OS_WINDOWS_PERFDISK_DIABLEDstatic java.lang.StringOSHI_OS_WINDOWS_PERFOS_DIABLEDstatic java.lang.StringOSHI_OS_WINDOWS_PERFPROC_DIABLEDstatic java.lang.StringOSHI_OS_WINDOWS_PROCSTATE_SUSPENDEDprivate static java.lang.StringOSHI_PROPERTIESstatic java.lang.StringOSHI_PSEUDO_FILESYSTEM_TYPESstatic java.lang.StringOSHI_UTIL_DEV_PATHstatic java.lang.StringOSHI_UTIL_MEMOIZER_EXPIRATIONstatic java.lang.StringOSHI_UTIL_PROC_PATHstatic java.lang.StringOSHI_UTIL_SYS_PATHstatic java.lang.StringOSHI_UTIL_WMI_TIMEOUT
-
Constructor Summary
Constructors Modifier Constructor Description privateGlobalConfig()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclear()Clear the configuration.static java.lang.Stringget(java.lang.String key)Get the property associated with the given key.static booleanget(java.lang.String key, boolean def)Get thebooleanproperty associated with the given key.static doubleget(java.lang.String key, double def)Get thedoubleproperty associated with the given key.static intget(java.lang.String key, int def)Get theintproperty associated with the given key.static java.lang.Stringget(java.lang.String key, java.lang.String def)Get theStringproperty associated with the given key.static voidload(java.util.Properties properties)Load the givenPropertiesinto the global configuration.static voidremove(java.lang.String key)Reset the given property to its default value.static voidset(java.lang.String key, java.lang.Object val)Set the given property, overwriting any existing value.
-
-
-
Field Detail
-
OSHI_PROPERTIES
private static final java.lang.String OSHI_PROPERTIES
- See Also:
- Constant Field Values
-
CONFIG
private static final java.util.Properties CONFIG
-
OSHI_UTIL_MEMOIZER_EXPIRATION
public static final java.lang.String OSHI_UTIL_MEMOIZER_EXPIRATION
- See Also:
- Constant Field Values
-
OSHI_UTIL_WMI_TIMEOUT
public static final java.lang.String OSHI_UTIL_WMI_TIMEOUT
- See Also:
- Constant Field Values
-
OSHI_UTIL_PROC_PATH
public static final java.lang.String OSHI_UTIL_PROC_PATH
- See Also:
- Constant Field Values
-
OSHI_UTIL_SYS_PATH
public static final java.lang.String OSHI_UTIL_SYS_PATH
- See Also:
- Constant Field Values
-
OSHI_UTIL_DEV_PATH
public static final java.lang.String OSHI_UTIL_DEV_PATH
- See Also:
- Constant Field Values
-
OSHI_PSEUDO_FILESYSTEM_TYPES
public static final java.lang.String OSHI_PSEUDO_FILESYSTEM_TYPES
- See Also:
- Constant Field Values
-
OSHI_NETWORK_FILESYSTEM_TYPES
public static final java.lang.String OSHI_NETWORK_FILESYSTEM_TYPES
- See Also:
- Constant Field Values
-
OSHI_OS_LINUX_ALLOWUDEV
public static final java.lang.String OSHI_OS_LINUX_ALLOWUDEV
- See Also:
- Constant Field Values
-
OSHI_OS_LINUX_PROCFS_LOGWARNING
public static final java.lang.String OSHI_OS_LINUX_PROCFS_LOGWARNING
- See Also:
- Constant Field Values
-
OSHI_OS_MAC_SYSCTL_LOGWARNING
public static final java.lang.String OSHI_OS_MAC_SYSCTL_LOGWARNING
- See Also:
- Constant Field Values
-
OSHI_OS_WINDOWS_EVENTLOG
public static final java.lang.String OSHI_OS_WINDOWS_EVENTLOG
- See Also:
- Constant Field Values
-
OSHI_OS_WINDOWS_PROCSTATE_SUSPENDED
public static final java.lang.String OSHI_OS_WINDOWS_PROCSTATE_SUSPENDED
- See Also:
- Constant Field Values
-
OSHI_OS_WINDOWS_COMMANDLINE_BATCH
public static final java.lang.String OSHI_OS_WINDOWS_COMMANDLINE_BATCH
- See Also:
- Constant Field Values
-
OSHI_OS_WINDOWS_HKEYPERFDATA
public static final java.lang.String OSHI_OS_WINDOWS_HKEYPERFDATA
- See Also:
- Constant Field Values
-
OSHI_OS_WINDOWS_LEGACY_SYSTEM_COUNTERS
public static final java.lang.String OSHI_OS_WINDOWS_LEGACY_SYSTEM_COUNTERS
- See Also:
- Constant Field Values
-
OSHI_OS_WINDOWS_LOADAVERAGE
public static final java.lang.String OSHI_OS_WINDOWS_LOADAVERAGE
- See Also:
- Constant Field Values
-
OSHI_OS_WINDOWS_CPU_UTILITY
public static final java.lang.String OSHI_OS_WINDOWS_CPU_UTILITY
- See Also:
- Constant Field Values
-
OSHI_OS_WINDOWS_PERFDISK_DIABLED
public static final java.lang.String OSHI_OS_WINDOWS_PERFDISK_DIABLED
- See Also:
- Constant Field Values
-
OSHI_OS_WINDOWS_PERFOS_DIABLED
public static final java.lang.String OSHI_OS_WINDOWS_PERFOS_DIABLED
- See Also:
- Constant Field Values
-
OSHI_OS_WINDOWS_PERFPROC_DIABLED
public static final java.lang.String OSHI_OS_WINDOWS_PERFPROC_DIABLED
- See Also:
- Constant Field Values
-
OSHI_OS_UNIX_WHOCOMMAND
public static final java.lang.String OSHI_OS_UNIX_WHOCOMMAND
- See Also:
- Constant Field Values
-
OSHI_OS_SOLARIS_ALLOWKSTAT2
public static final java.lang.String OSHI_OS_SOLARIS_ALLOWKSTAT2
- See Also:
- Constant Field Values
-
-
Method Detail
-
get
public static java.lang.String get(java.lang.String key)
Get the property associated with the given key.- Parameters:
key- The property key- Returns:
- The property value if it exists, or null otherwise
-
get
public static java.lang.String get(java.lang.String key, java.lang.String def)Get theStringproperty associated with the given key.- Parameters:
key- The property keydef- The default value- Returns:
- The property value or the given default if not found
-
get
public static int get(java.lang.String key, int def)Get theintproperty associated with the given key.- Parameters:
key- The property keydef- The default value- Returns:
- The property value or the given default if not found
-
get
public static double get(java.lang.String key, double def)Get thedoubleproperty associated with the given key.- Parameters:
key- The property keydef- The default value- Returns:
- The property value or the given default if not found
-
get
public static boolean get(java.lang.String key, boolean def)Get thebooleanproperty associated with the given key.- Parameters:
key- The property keydef- The default value- Returns:
- The property value or the given default if not found
-
set
public static void set(java.lang.String key, java.lang.Object val)Set the given property, overwriting any existing value. If the given value isnull, the property is removed.- Parameters:
key- The property keyval- The new value
-
remove
public static void remove(java.lang.String key)
Reset the given property to its default value.- Parameters:
key- The property key
-
clear
public static void clear()
Clear the configuration.
-
load
public static void load(java.util.Properties properties)
Load the givenPropertiesinto the global configuration.- Parameters:
properties- The new properties
-
-