org.apache.openjpa.lib.conf
Class Configurations

java.lang.Object
  extended by org.apache.openjpa.lib.conf.Configurations

public class Configurations
extends Object

Utility methods dealing with configuration.

Author:
Abe White

Constructor Summary
Configurations()
           
 
Method Summary
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 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 boolean containsProperty(String key, Map props)
          Test whether the map contains the given 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.
static String getPlugin(String clsName, String props)
          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 key, Map props)
          Get the property under the given key, prefixed with any possible configuration prefix.
static Object lookup(String name)
          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.
static Options parseProperties(String properties)
          Parse a set of properties from a comma-separated string.
static void populateConfiguration(Configuration conf, Options opts)
          Set the given Configuration instance from the command line options provided.
static Object removeProperty(String key, Map props)
          Remove the property under the given key, prefixed with any possible configuration prefix.
static String serializeProperties(Map map)
          Turn a set of properties into a comma-separated string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Configurations

public Configurations()
Method Detail

getClassName

public static String getClassName(String plugin)
Return the class name from the given plugin string, or null if none.


getProperties

public static String getProperties(String plugin)
Return the properties part of the given plugin string, or null if none.


getPlugin

public static String getPlugin(String clsName,
                               String props)
Combine the given class name and properties into a plugin string.


newInstance

public static Object newInstance(String clsName,
                                 ClassLoader loader)
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.


populateConfiguration

public static void populateConfiguration(Configuration conf,
                                         Options opts)
Set the given Configuration instance from the command line options provided. All property names of the given configuration are recognized; additionally, if a properties or p 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.


configureInstance

public 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. 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

public 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. 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. If configurationName is non-null, validates that setter methods exist for the properties.

Throws:
RuntimeException - on configuration error

serializeProperties

public static String serializeProperties(Map map)
Turn a set of properties into a comma-separated string.


parseProperties

public static Options parseProperties(String properties)
Parse a set of properties from a comma-separated string.


lookup

public static Object lookup(String name)
Looks up the given name in JNDI. If the name is null, null is returned.


containsProperty

public static boolean containsProperty(String key,
                                       Map props)
Test whether the map contains the given key, prefixed with any possible configuration prefix.


getProperty

public static Object getProperty(String key,
                                 Map props)
Get the property under the given key, prefixed with any possible configuration prefix.


removeProperty

public static Object removeProperty(String key,
                                    Map props)
Remove the property under the given key, prefixed with any possible configuration prefix.



Copyright © 2006 Apache Software Foundation. All Rights Reserved.