public final class PropertiesHelper
extends java.lang.Object
org.glassfish.jersey.server.ResourceConfig
and Configuration
properties.Modifier and Type | Field and Description |
---|---|
private static java.util.logging.Logger |
LOGGER |
Modifier | Constructor and Description |
---|---|
private |
PropertiesHelper()
Prevent instantiation.
|
Modifier and Type | Method and Description |
---|---|
static <T> T |
convertValue(java.lang.Object value,
java.lang.Class<T> type)
Convert
Object value to a value of the specified class type. |
private static java.lang.Object |
getLegacyFallbackValue(java.util.Map<java.lang.String,?> properties,
java.util.Map<java.lang.String,java.lang.String> legacyFallbackMap,
java.lang.String key) |
static java.lang.String |
getPropertyNameForRuntime(java.lang.String key,
javax.ws.rs.RuntimeType runtimeType)
Returns specific property value for given
RuntimeType . |
static java.security.PrivilegedAction<java.util.Properties> |
getSystemProperties()
Get system properties.
|
static java.security.PrivilegedAction<java.lang.String> |
getSystemProperty(java.lang.String name)
Get system property.
|
static java.security.PrivilegedAction<java.lang.String> |
getSystemProperty(java.lang.String name,
java.lang.String def)
Get system property.
|
static <T> T |
getValue(java.util.Map<java.lang.String,?> properties,
javax.ws.rs.RuntimeType runtimeType,
java.lang.String key,
java.lang.Class<T> type,
java.util.Map<java.lang.String,java.lang.String> legacyMap)
Returns value of a specified property.
|
static <T> T |
getValue(java.util.Map<java.lang.String,?> properties,
javax.ws.rs.RuntimeType runtimeType,
java.lang.String key,
T defaultValue,
java.lang.Class<T> type,
java.util.Map<java.lang.String,java.lang.String> legacyMap)
Returns value of a specified property.
|
static <T> T |
getValue(java.util.Map<java.lang.String,?> properties,
javax.ws.rs.RuntimeType runtimeType,
java.lang.String key,
T defaultValue,
java.util.Map<java.lang.String,java.lang.String> legacyMap)
Return value of a specified property.
|
static <T> T |
getValue(java.util.Map<java.lang.String,?> properties,
java.lang.String key,
java.lang.Class<T> type,
java.util.Map<java.lang.String,java.lang.String> legacyMap)
Returns value of a specified property.
|
static <T> T |
getValue(java.util.Map<java.lang.String,?> properties,
java.lang.String key,
T defaultValue,
java.lang.Class<T> type,
java.util.Map<java.lang.String,java.lang.String> legacyMap)
Returns value of a specified property.
|
static <T> T |
getValue(java.util.Map<java.lang.String,?> properties,
java.lang.String key,
T defaultValue,
java.util.Map<java.lang.String,java.lang.String> legacyMap)
Return value of a specified property.
|
static boolean |
isProperty(java.util.Map<java.lang.String,java.lang.Object> properties,
java.lang.String name)
Get the value of the property with a given name converted to
boolean . |
static boolean |
isProperty(java.lang.Object value)
Get the value of the property converted to
boolean . |
public static java.security.PrivilegedAction<java.util.Properties> getSystemProperties()
System.getProperties()
while running it in a privileged
code block.public static java.security.PrivilegedAction<java.lang.String> getSystemProperty(java.lang.String name)
System.getProperty(String)
while running it in a privileged
code block.name
- system property name.null
if there's no such system property.public static java.security.PrivilegedAction<java.lang.String> getSystemProperty(java.lang.String name, java.lang.String def)
System.getProperty(String)
while running it in a privileged
code block.name
- system property name.def
- default property value.public static <T> T getValue(java.util.Map<java.lang.String,?> properties, java.lang.String key, T defaultValue, java.util.Map<java.lang.String,java.lang.String> legacyMap)
PropertyHelper.getValue(properties, key, defaultValue, (Class<T>) defaultValue.getClass())
T
- Type of the property value.properties
- Map of properties to get the property value from.key
- Name of the property.defaultValue
- Default value to be returned if the specified property is not set or cannot be read.legacyMap
- Legacy fallback map, where key is the actual property name, value is the old property namepublic static <T> T getValue(java.util.Map<java.lang.String,?> properties, javax.ws.rs.RuntimeType runtimeType, java.lang.String key, T defaultValue, java.util.Map<java.lang.String,java.lang.String> legacyMap)
PropertyHelper.getValue(properties, runtimeType, key, defaultValue, (Class<T>) defaultValue.getClass())
T
- Type of the property value.properties
- Map of properties to get the property value from.runtimeType
- Runtime type which is used to check whether there is a property with the same
key
but post-fixed by runtime type (.server
or .client
) which would override the key
property.key
- Name of the property.defaultValue
- Default value to be returned if the specified property is not set or cannot be read.legacyMap
- Legacy fallback map, where key is the actual property name, value is the old property namepublic static <T> T getValue(java.util.Map<java.lang.String,?> properties, java.lang.String key, T defaultValue, java.lang.Class<T> type, java.util.Map<java.lang.String,java.lang.String> legacyMap)
T
- Type of the property value.properties
- Map of properties to get the property value from.key
- Name of the property.defaultValue
- Default value of the property.type
- Type to retrieve the value as.legacyMap
- Legacy fallback map, where key is the actual property name, value is the old property namepublic static <T> T getValue(java.util.Map<java.lang.String,?> properties, javax.ws.rs.RuntimeType runtimeType, java.lang.String key, T defaultValue, java.lang.Class<T> type, java.util.Map<java.lang.String,java.lang.String> legacyMap)
T
- Type of the property value.properties
- Map of properties to get the property value from.runtimeType
- Runtime type which is used to check whether there is a property with the same
key
but post-fixed by runtime type (.server
or .client
) which would override the key
property.key
- Name of the property.defaultValue
- Default value of the property.type
- Type to retrieve the value as.legacyMap
- Legacy fallback map, where key is the actual property name, value is the old property namepublic static <T> T getValue(java.util.Map<java.lang.String,?> properties, java.lang.String key, java.lang.Class<T> type, java.util.Map<java.lang.String,java.lang.String> legacyMap)
T
- Type of the property value.properties
- Map of properties to get the property value from.key
- Name of the property.type
- Type to retrieve the value as.legacyMap
- Legacy fallback map, where key is the actual property name, value is the old property namepublic static <T> T getValue(java.util.Map<java.lang.String,?> properties, javax.ws.rs.RuntimeType runtimeType, java.lang.String key, java.lang.Class<T> type, java.util.Map<java.lang.String,java.lang.String> legacyMap)
T
- Type of the property value.properties
- Map of properties to get the property value from.runtimeType
- Runtime type which is used to check whether there is a property with the same
key
but post-fixed by runtime type (.server
or .client
) which would override the key
property.key
- Name of the property.type
- Type to retrieve the value as.public static java.lang.String getPropertyNameForRuntime(java.lang.String key, javax.ws.rs.RuntimeType runtimeType)
RuntimeType
.
Some properties have complementary client and server versions along with a common version (effective for both environments,
if the specific one is not set). This methods returns a specific name for the environment (determined by convention),
if runtime is not null, the property is a Jersey property name (starts with jersey.config
) and does not contain
a runtime specific part already. If those conditions are not met, original property name is returned.key
- property nameruntimeType
- runtime typeprivate static java.lang.Object getLegacyFallbackValue(java.util.Map<java.lang.String,?> properties, java.util.Map<java.lang.String,java.lang.String> legacyFallbackMap, java.lang.String key)
public static <T> T convertValue(java.lang.Object value, java.lang.Class<T> type)
Object
value to a value of the specified class type.T
- converted value type.value
- Object
value to convert.type
- conversion type.public static boolean isProperty(java.util.Map<java.lang.String,java.lang.Object> properties, java.lang.String name)
boolean
. Returns false
if the value is
not convertible.properties
- key-value map of properties.name
- property name.boolean
property value or false
if the property is not convertible.public static boolean isProperty(java.lang.Object value)
boolean
. Returns false
if the value is not convertible.value
- property value.boolean
property value or false
if the property is not convertible.