org.apache.openjpa.lib.conf
Class Configurations

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

public class Configurations
extends java.lang.Object

Utility methods dealing with configuration.

Author:
Abe White

Constructor Summary
Configurations()
           
 
Method Summary
static void configureInstance(java.lang.Object obj, Configuration conf, java.util.Properties properties)
          Configures the given object with the given properties by matching the properties string to the object's setter methods.
static void configureInstance(java.lang.Object obj, Configuration conf, java.util.Properties properties, java.lang.String configurationName)
          Configures the given object with the given properties by matching the properties string to the object's setter methods.
static void configureInstance(java.lang.Object obj, Configuration conf, java.lang.String properties)
          Configures the given object with the given properties by matching the properties string to the object's setter methods.
static void configureInstance(java.lang.Object obj, Configuration conf, java.lang.String properties, java.lang.String configurationName)
          Configures the given object with the given properties by matching the properties string to the object's setter methods.
static java.lang.String getClassName(java.lang.String plugin)
          Return the class name from the given plugin string, or null if none.
static java.lang.String getPlugin(java.lang.String clsName, java.lang.String props)
          Combine the given class name and properties into a plugin string.
static java.lang.String getProperties(java.lang.String plugin)
          Return the properties part of the given plugin string, or null if none.
static ConfigurationProvider load(java.io.File file, java.lang.ClassLoader loader)
          Return a ConfigurationProvider that has parsed the given file.
static ConfigurationProvider load(java.lang.String resource, java.lang.ClassLoader loader)
          Return a ConfigurationProvider that has parsed the given resource.
static ConfigurationProvider loadDefaults(java.lang.ClassLoader loader)
          Return a ConfigurationProvider that has parsed system defaults.
static java.lang.Object lookup(java.lang.String name)
          Looks up the given name in JNDI.
static java.lang.Object newInstance(java.lang.String clsName, java.lang.ClassLoader loader)
          Create the instance with the given class name, using the given class loader.
static java.lang.Object newInstance(java.lang.String clsName, Configuration conf, java.lang.String props, java.lang.ClassLoader loader)
          Create and configure an instance with the given class name and properties.
static Options parseProperties(java.lang.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 java.lang.String serializeProperties(java.util.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 java.lang.String getClassName(java.lang.String plugin)
Return the class name from the given plugin string, or null if none.


getProperties

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


getPlugin

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


newInstance

public static java.lang.Object newInstance(java.lang.String clsName,
                                           java.lang.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 java.lang.Object newInstance(java.lang.String clsName,
                                           Configuration conf,
                                           java.lang.String props,
                                           java.lang.ClassLoader loader)
Create and configure an instance with the given class name and properties.


configureInstance

public static void configureInstance(java.lang.Object obj,
                                     Configuration conf,
                                     java.lang.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:
java.lang.RuntimeException - on configuration error

configureInstance

public static void configureInstance(java.lang.Object obj,
                                     Configuration conf,
                                     java.lang.String properties,
                                     java.lang.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:
java.lang.RuntimeException - on configuration error

configureInstance

public static void configureInstance(java.lang.Object obj,
                                     Configuration conf,
                                     java.util.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:
java.lang.RuntimeException - on configuration error

configureInstance

public static void configureInstance(java.lang.Object obj,
                                     Configuration conf,
                                     java.util.Properties properties,
                                     java.lang.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:
java.lang.RuntimeException - on configuration error

serializeProperties

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


parseProperties

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


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.


loadDefaults

public static ConfigurationProvider loadDefaults(java.lang.ClassLoader loader)
Return a ConfigurationProvider that has parsed system defaults.


load

public static ConfigurationProvider load(java.lang.String resource,
                                         java.lang.ClassLoader loader)
Return a ConfigurationProvider that has parsed the given resource. Throws MissingResourceException if resource does not exist.


load

public static ConfigurationProvider load(java.io.File file,
                                         java.lang.ClassLoader loader)
Return a ConfigurationProvider that has parsed the given file. Throws MissingResourceException if file does not exist.


lookup

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



Copyright © 2006 Apache Software Foundation. All Rights Reserved.