com.ibm.wsspi.kernel.service.utils
Class MetatypeUtils
- java.lang.Object
com.ibm.wsspi.kernel.service.utils.MetatypeUtils
- public class MetatypeUtils
- extends java.lang.Object
The presence of the Metatype service will cause ConfigAdmin to use real types (in addition to String) as values in the the configuration properties provided to declarative services components.
This class provides utility methods for retrieving a desired type (a boolean, a long, an array of strings.. ) from a component's configuration properties. They handle objects of either type (those already created/populated as the right type, or values that are still encoded as strings).
Constructor Summary
Constructor and Description |
---|
MetatypeUtils()
|
Method Summary
Modifier and Type | Method and Description |
---|---|
|
evaluateDuration(java.lang.String strVal,java.util.concurrent.TimeUnit endUnit)
Converts a string value representing a unit of time into a Long value.
|
|
parseBoolean(java.lang.Object configAlias,java.lang.String propertyKey,java.lang.Object obj,boolean defaultValue)
Parse a boolean from the provided config value: checks for whether or not
the object read from the Service/Component configuration is a String
or a Metatype converted boolean.
|
|
parseDuration(java.lang.Object configAlias,java.lang.String propertyKey,java.lang.Object obj,long defaultValue)
Parse a duration from the provided config value: checks for whether or not
the object read from the Service/Component configuration is a String
or a Metatype converted long duration value
|
|
parseDuration(java.lang.Object configAlias,java.lang.String propertyKey,java.lang.Object obj,long defaultValue,java.util.concurrent.TimeUnit units)
Parse a duration from the provided config value: checks for whether or not
the object read from the Service/Component configuration is a String
or a Metatype converted long duration value
|
|
parseInteger(java.lang.Object configAlias,java.lang.String propertyKey,java.lang.Object obj,int defaultValue)
Parse a int from the provided config value: checks for whether or not
the object read from the Service/Component configuration is a String
or a Metatype converted int
|
|
parseIntegerArray(java.lang.Object configAlias,java.lang.String propertyKey,java.lang.Object obj,int[] defaultValue)
Parse a string array from the provided config value: returns
an array of strings generated from either a comma-separated single
string value, or a metatype generated string array.
|
|
parseLong(java.lang.Object configAlias,java.lang.String propertyKey,java.lang.Object obj,long defaultValue)
Parse a long from the provided config value: checks for whether or not
the object read from the Service/Component configuration is a String
or a Metatype converted long
|
|
parseStringArray(java.lang.Object configAlias,java.lang.String propertyKey,java.lang.Object obj,java.lang.String[] defaultValue)
Parse a string array from the provided config value: returns
an array of strings generated from either a comma-separated single
string value, or a metatype generated string array.
|
|
parseStringCollection(java.lang.Object configAlias,java.lang.String propertyKey,java.lang.Object obj,java.util.Collection<java.lang.String> defaultValue)
Parse a string collection from the provided config value: returns
a collection of strings generated from either a comma-separated single
string value, or a metatype provided string collection.
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail
MetatypeUtils
- public MetatypeUtils()
Method Detail
parseBoolean
- public static boolean parseBoolean( java.lang.Object configAlias,
- java.lang.String propertyKey,
- java.lang.Object obj,
- boolean defaultValue)
configAlias
- Name of config (pid or alias) associated with a registered service
or DS component. propertyKey
- The key used to retrieve the property value from the map.
Used in the warning message if the value is badly formed. obj
- The object retrieved from the configuration property map/dictionary. java.lang.IllegalArgumentException
- If value is not a String/Boolean, or if the String
boolean is not "true" or "false" (ignoring case) parseStringArray
- public static java.lang.String[] parseStringArray( java.lang.Object configAlias,
- java.lang.String propertyKey,
- java.lang.Object obj,
- java.lang.String[] defaultValue)
If an exception occurs converting the object parameter: A translated warning message will be issued using the provided propertyKey and object as parameters. FFDC for the exception is suppressed: Callers should handle the thrown IllegalArgumentException as appropriate.
configAlias
- Name of config (pid or alias) associated with a registered service
or DS component. propertyKey
- The key used to retrieve the property value from the map.
Used in the warning message if the value is badly formed. obj
- The object retrieved from the configuration property map/dictionary. defaultValue
- The default value that should be applied if the object is null. java.lang.IllegalArgumentException
- If value is not a String or String array, or if an error
occurs while converting/casting the object to the return parameter type. parseStringCollection
- public static java.util.Collection<java.lang.String> parseStringCollection( java.lang.Object configAlias,
- java.lang.String propertyKey,
- java.lang.Object obj,
- java.util.Collection<java.lang.String> defaultValue)
If an exception occurs converting the object parameter: A translated warning message will be issued using the provided propertyKey and object as parameters. FFDC for the exception is suppressed: Callers should handle the thrown IllegalArgumentException as appropriate.
configAlias
- Name of config (pid or alias) associated with a registered service
or DS component. propertyKey
- The key used to retrieve the property value from the map.
Used in the warning message if the value is badly formed. obj
- The object retrieved from the configuration property map/dictionary. defaultValue
- The default value that should be applied if the object is null. java.lang.IllegalArgumentException
- If value is not a String, String collection, or String array, or if an error
occurs while converting/casting the object to the return parameter type. parseLong
- public static long parseLong(java.lang.Object configAlias,
- java.lang.String propertyKey,
- java.lang.Object obj,
- long defaultValue)
If an exception occurs converting the object parameter: A translated warning message will be issued using the provided propertyKey and object as parameters. FFDC for the exception is suppressed: Callers should handle the thrown IllegalArgumentException as appropriate.
configAlias
- Name of config (pid or alias) associated with a registered service
or DS component. propertyKey
- The key used to retrieve the property value from the map.
Used in the warning message if the value is badly formed. obj
- The object retrieved from the configuration property map/dictionary. defaultValue
- The default value that should be applied if the object is null. java.lang.IllegalArgumentException
- If value is not a String/Short/Integer/Long, or if an error
occurs while converting/casting the object to the return parameter type. parseInteger
- public static int parseInteger( java.lang.Object configAlias,
- java.lang.String propertyKey,
- java.lang.Object obj,
- int defaultValue)
If an exception occurs converting the object parameter: A translated warning message will be issued using the provided propertyKey and object as parameters. FFDC for the exception is suppressed: Callers should handle the thrown IllegalArgumentException as appropriate.
configAlias
- Name of config (pid or alias) associated with a registered service
or DS component. propertyKey
- The key used to retrieve the property value from the map.
Used in the warning message if the value is badly formed. obj
- The object retrieved from the configuration property map/dictionary. defaultValue
- The default value that should be applied if the object is null. java.lang.IllegalArgumentException
- If value is not a String/Short/Integer/Long, or if an error
occurs while converting/casting the object to the return parameter type. parseIntegerArray
- public static int[] parseIntegerArray( java.lang.Object configAlias,
- java.lang.String propertyKey,
- java.lang.Object obj,
- int[] defaultValue)
If an exception occurs converting the object parameter: A translated warning message will be issued using the provided propertyKey and object as parameters. FFDC for the exception is suppressed: Callers should handle the thrown IllegalArgumentException as appropriate.
configAlias
- Name of config (pid or alias) associated with a registered service
or DS component. propertyKey
- The key used to retrieve the property value from the map.
Used in the warning message if the value is badly formed. obj
- The object retrieved from the configuration property map/dictionary. defaultValue
- The default value that should be applied if the object is null. java.lang.IllegalArgumentException
- If value is not a String or String array, or if an error
occurs while converting/casting the object to the return parameter type. parseDuration
- public static long parseDuration( java.lang.Object configAlias,
- java.lang.String propertyKey,
- java.lang.Object obj,
- long defaultValue)
If an exception occurs converting the object parameter: A translated warning message will be issued using the provided propertyKey and object as parameters. FFDC for the exception is suppressed: Callers should handle the thrown IllegalArgumentException as appropriate.
configAlias
- Name of config (pid or alias) associated with a registered service
or DS component. propertyKey
- The key used to retrieve the property value from the map.
Used in the warning message if the value is badly formed. obj
- The object retrieved from the configuration property map/dictionary. defaultValue
- The default value that should be applied if the object is null. java.lang.IllegalArgumentException
- If value is not a Long, or if an error
occurs while converting/casting the object to the return parameter type. parseDuration
- public static long parseDuration( java.lang.Object configAlias,
- java.lang.String propertyKey,
- java.lang.Object obj,
- long defaultValue,
- java.util.concurrent.TimeUnit units)
If an exception occurs converting the object parameter: A translated warning message will be issued using the provided propertyKey and object as parameters. FFDC for the exception is suppressed: Callers should handle the thrown IllegalArgumentException as appropriate.
configAlias
- Name of config (pid or alias) associated with a registered service
or DS component. propertyKey
- The key used to retrieve the property value from the map.
Used in the warning message if the value is badly formed. obj
- The object retrieved from the configuration property map/dictionary. defaultValue
- The default value that should be applied if the object is null. units
- The unit of time for the duration value. This is only used when
converting from a String value. java.lang.IllegalArgumentException
- If value is not a String/Short/Integer/Long, or if an error
occurs while converting/casting the object to the return parameter type. evaluateDuration
- public static java.lang.Long evaluateDuration( java.lang.String strVal,
- java.util.concurrent.TimeUnit endUnit)
strVal
- A String representing a unit of time.
If an exception occurs converting the object parameter: A translated warning message will be issued using the provided propertyKey and object as parameters. FFDC for the exception is suppressed: Callers should handle the thrown IllegalArgumentException as appropriate.