Package org.apache.openjpa.lib.conf
Class Configurations
java.lang.Object
org.apache.openjpa.lib.conf.Configurations
Utility methods dealing with configuration.
- Author:
- Abe White
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
combinePlugins
(String orig, String override) Return a plugin string that combines the properties of the given plugin strings, where properties ofoverride
will override the same properties oforig
.static void
configureInstance
(Object obj, Configuration conf, String properties) Configures the given object with the given properties by matching the properties string to the object's setter methods.static void
configureInstance
(Object obj, Configuration conf, String properties, String configurationName) Configures the given object with the given properties by matching the properties string to the object's setter methods.static void
configureInstance
(Object obj, Configuration conf, Properties properties) Configures the given object with the given properties by matching the properties string to the object's setter methods.static void
configureInstance
(Object obj, Configuration conf, Properties properties, String configurationName) Configures the given object with the given properties by matching the properties string to the object's setter methods.static boolean
containsProperty
(String partialKey, Map props) Test whether the map contains the given partial key, prefixed with any possible configuration prefix.static boolean
containsProperty
(Value value, Map props) Test whether the map contains the given partial key, prefixed with any possible configuration prefix.static String
getClassName
(String plugin) Return the class name from the given plugin string, or null if none.Return a Listof all the fully-qualified anchors specified in the properties location listed in opts
.static String
Combine the given class name and properties into a plugin string.static String
getProperties
(String plugin) Return the properties part of the given plugin string, or null if none.static Object
getProperty
(String partialKey, Map m) Get the property under the given partial key, prefixed with any possible configuration prefix.static Object
Looks up the given name in JNDI.static Object
newInstance
(String clsName, ClassLoader loader) Create the instance with the given class name, using the given class loader.static Object
newInstance
(String clsName, Configuration conf, String props, ClassLoader loader) Create and configure an instance with the given class name and properties as a String.static Object
newInstance
(String clsName, Configuration conf, Properties props, ClassLoader loader) Create and configure an instance with the given class name and properties.parseConfigResource
(String props) static Options
parseProperties
(String properties) Parse a set of properties from a comma-separated string.static void
populateConfiguration
(Configuration conf, Options opts) Set the givenConfiguration
instance from the command line options provided.static Object
removeProperty
(String partialKey, Map props) Remove the property under the given partial key, prefixed with any possible configuration prefix.static void
removeProperty
(String partialKey, Map<?, ?> remaining, Map<?, ?> props) static boolean
runAgainstAllAnchors
(Options opts, Configurations.Runnable runnable) Runsrunnable
against all the anchors in the configuration pointed to byopts
.static String
serializeProperties
(Map map) Turn a set of properties into a comma-separated string.
-
Field Details
-
CONFIG_RESOURCE_PATH
- See Also:
-
CONFIG_RESOURCE_ANCHOR
- See Also:
-
-
Constructor Details
-
Configurations
public Configurations()
-
-
Method Details
-
getClassName
Return the class name from the given plugin string, or null if none. -
getProperties
Return the properties part of the given plugin string, or null if none. -
getPlugin
Combine the given class name and properties into a plugin string. -
combinePlugins
Return a plugin string that combines the properties of the given plugin strings, where properties ofoverride
will override the same properties oforig
. -
newInstance
Create the instance with the given class name, using the given class loader. No configuration of the instance is performed by this method. -
newInstance
public static Object newInstance(String clsName, Configuration conf, String props, ClassLoader loader) Create and configure an instance with the given class name and properties as a String. -
newInstance
public static Object newInstance(String clsName, Configuration conf, Properties props, ClassLoader loader) Create and configure an instance with the given class name and properties. -
getFullyQualifiedAnchorsInPropertiesLocation
Return a Listof all the fully-qualified anchors specified in the properties location listed in opts
. If no properties location is listed inopts
, this returns whatever the product derivations can find in their default configurations. If the properties location specified inopts
already contains an anchor spec, this returns that anchor. Note that in this fully-qualified-input case, the logic involving product derivations and resource parsing is short-circuited, so this method should not be used as a means to test that a particular anchor is defined in a given location by invoking with a fully-qualified anchor. This does not mutateopts
.- Since:
- 1.1.0
-
populateConfiguration
Set the givenConfiguration
instance from the command line options provided. All property names of the given configuration are recognized; additionally, if aproperties
orp
argument exists, the resource it points to will be loaded and set into the given configuration instance. It can point to either a file or a resource name. -
parseConfigResource
-
configureInstance
Configures the given object with the given properties by matching the properties string to the object's setter methods. The properties string should be in the form "prop1=val1, prop2=val2 ...". Does not validate that setter methods exist for the properties.- Throws:
RuntimeException
- on configuration error
-
configureInstance
public static void configureInstance(Object obj, Configuration conf, String properties, String configurationName) Configures the given object with the given properties by matching the properties string to the object's setter methods. The properties string should be in the form "prop1=val1, prop2=val2 ...". Validates that setter methods exist for the properties.- Throws:
RuntimeException
- on configuration error
-
configureInstance
Configures the given object with the given properties by matching the properties string to the object's setter methods. Does not validate that setter methods exist for the properties.- Throws:
RuntimeException
- on configuration error
-
configureInstance
public static void configureInstance(Object obj, Configuration conf, Properties properties, String configurationName) Configures the given object with the given properties by matching the properties string to the object's setter methods. IfconfigurationName
is non-null
, validates that setter methods exist for the properties.- Throws:
RuntimeException
- on configuration error
-
serializeProperties
Turn a set of properties into a comma-separated string. -
parseProperties
Parse a set of properties from a comma-separated string. -
lookup
Looks up the given name in JNDI. If the name is null, null is returned. -
containsProperty
Test whether the map contains the given partial key, prefixed with any possible configuration prefix. -
containsProperty
Test whether the map contains the given partial key, prefixed with any possible configuration prefix. -
getProperty
Get the property under the given partial key, prefixed with any possible configuration prefix. -
removeProperty
Remove the property under the given partial key, prefixed with any possible configuration prefix. -
removeProperty
-
runAgainstAllAnchors
Runsrunnable
against all the anchors in the configuration pointed to byopts
. Each invocation gets a fresh clone ofopts
with theproperties
option set appropriately.- Since:
- 1.1.0
-