org.unitils.core.util
Class ConfigUtils

java.lang.Object
  extended by org.unitils.core.util.ConfigUtils

public class ConfigUtils
extends Object

Class containing configuration related utilities

Author:
Filip Neven, Tim Ducheyne

Constructor Summary
ConfigUtils()
           
 
Method Summary
static String getConfiguredClassName(Class<?> type, Properties configuration, String... implementationDiscriminatorValues)
          Retrieves the class name of the concrete instance of the class with the given type as configured by the given Configuration.
static
<T extends Configurable>
T
getConfiguredInstanceOf(Class<? extends T> type, Properties configuration, String... implementationDiscriminatorValues)
          Retrieves the concrete instance of the class with the given type as configured by the given Configuration.
static
<T> T
getInstanceOf(Class<? extends T> type, Properties configuration, String... implementationDiscriminatorValues)
          Retrieves the concrete instance of the class with the given type as configured by the given Configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigUtils

public ConfigUtils()
Method Detail

getConfiguredInstanceOf

public static <T extends Configurable> T getConfiguredInstanceOf(Class<? extends T> type,
                                                                 Properties configuration,
                                                                 String... implementationDiscriminatorValues)
Retrieves the concrete instance of the class with the given type as configured by the given Configuration. Tries to retrieve a specific implementation first (propery key = fully qualified name of the interface type + '.impl.className.' + implementationDiscriminatorValue). If this key does not exist, the generally configured instance is retrieved (same property key without the implementationDiscriminatorValue).

Parameters:
type - The type of the instance
configuration - The configuration containing the necessary properties for configuring the instance
implementationDiscriminatorValues - The values that define which specific implementation class should be used. This is typically an environment specific property, like the DBMS that is used.
Returns:
The configured instance

getInstanceOf

public static <T> T getInstanceOf(Class<? extends T> type,
                                  Properties configuration,
                                  String... implementationDiscriminatorValues)
Retrieves the concrete instance of the class with the given type as configured by the given Configuration. Tries to retrieve a specific implementation first (propery key = fully qualified name of the interface type + '.impl.className.' + implementationDiscriminatorValue). If this key does not exist, the generally configured instance is retrieved (same property key without the implementationDiscriminatorValue).

Parameters:
type - The type of the instance
configuration - The configuration containing the necessary properties for configuring the instance
implementationDiscriminatorValues - The values that define which specific implementation class should be used. This is typically an environment specific property, like the DBMS that is used.
Returns:
The configured instance

getConfiguredClassName

public static String getConfiguredClassName(Class<?> type,
                                            Properties configuration,
                                            String... implementationDiscriminatorValues)
Retrieves the class name of the concrete instance of the class with the given type as configured by the given Configuration. Tries to retrieve a specific implementation first (propery key = fully qualified name of the interface type + '.impl.className.' + implementationDiscriminatorValue). If this key does not exist, the generally configured instance is retrieved (same property key without the implementationDiscriminatorValue).

Parameters:
type - The type of the instance
configuration - The configuration containing the necessary properties for configuring the instance
implementationDiscriminatorValues - The values that define which specific implementation class should be used. This is typically an environment specific property, like the DBMS that is used.
Returns:
The configured class name


Copyright © 2011. All Rights Reserved.