com.objectwave.configuration
Class DefaultConfigurationService

java.lang.Object
  |
  +--com.objectwave.configuration.DefaultConfigurationService
All Implemented Interfaces:
ConfigurationService

public class DefaultConfigurationService
extends java.lang.Object
implements ConfigurationService

Set the values of the property object from the properties provided by the property factory. By default it uses System.properties for configuration but this could be overridden by other configuration services.
The rules for finding values from the properties object is documented in the method definition of findValueToSet.

Version:
$Id: DefaultConfigurationService.java,v 2.4 2002/02/28 04:19:56 dave_hoag Exp $
Author:
dhoag
See Also:
findValueToSet(java.lang.String, java.util.Properties, java.lang.String), DefaultCreationStrategy

Nested Class Summary
static class DefaultConfigurationService.Test
           
 
Field Summary
protected  PropertyObjects propertyObjects
           
protected  ReflectiveHelper reflectiveHelper
           
 
Constructor Summary
DefaultConfigurationService()
          Constructor for the DefaultConfigurationService object
 
Method Summary
 java.lang.String findValueToSet(java.lang.String name, java.util.Properties props, java.lang.String categoryId)
          In the following example assume an attributeName of 'host' and a categoryId of 'com.objectwave.configuration.MyClass'.
 java.lang.String getCategoryId(PropertySource source)
          Categories are identified by the full name of the property source object.
protected  java.lang.Object getOrCreateDetail(PropertySource context, java.lang.String categoryId)
          Either find the existing detail object, or create a new instance if an exsting one is not found.
protected  java.lang.String getPackageName(java.lang.String className)
          Get the 'package name' from the class full name.
 java.lang.Object getPropertyHolder(PropertySource context)
          Create and return an instance of the PropertyDetail.
 java.lang.Object getPropertyHolder(PropertySource context, java.lang.String categoryId)
          Create and return an instance of the PropertyDetail.
protected  void initialize()
          Instantiate the object that will allow me to call the setMethods.
protected  boolean isCachingDetail()
           
 void setValues(java.util.Properties props, java.lang.String categoryId, java.lang.Object obj)
          Set all non null values on the provided object.
 void setValues(java.lang.String categoryId, java.lang.Object obj)
          Populate the object with the values found in the property object provided by the PropertyFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reflectiveHelper

protected ReflectiveHelper reflectiveHelper

propertyObjects

protected PropertyObjects propertyObjects
Constructor Detail

DefaultConfigurationService

public DefaultConfigurationService()
Constructor for the DefaultConfigurationService object

Method Detail

setValues

public void setValues(java.lang.String categoryId,
                      java.lang.Object obj)
               throws java.lang.reflect.InvocationTargetException,
                      java.lang.IllegalAccessException
Populate the object with the values found in the property object provided by the PropertyFactory.

Parameters:
categoryId - String a '.' delimited path. Like a package name.
obj - The PropertyDetail object that is being populated
Throws:
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

setValues

public void setValues(java.util.Properties props,
                      java.lang.String categoryId,
                      java.lang.Object obj)
               throws java.lang.reflect.InvocationTargetException,
                      java.lang.IllegalAccessException
Set all non null values on the provided object.

Parameters:
props - Properties The properties object from which we are looking for values.
categoryId - String a '.' delimited path. Like a package name.
obj - The PropertyDetail object that is being populated
Throws:
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

getPropertyHolder

public java.lang.Object getPropertyHolder(PropertySource context)
                                   throws ConfigurationException
Create and return an instance of the PropertyDetail. The instance will have its values set from the configuration service.

Specified by:
getPropertyHolder in interface ConfigurationService
Parameters:
context - We locate property holder by looking at the PropertySource
Returns:
The actual object containing the property values, Property Detail.
Throws:
ConfigurationException

getPropertyHolder

public java.lang.Object getPropertyHolder(PropertySource context,
                                          java.lang.String categoryId)
                                   throws ConfigurationException
Create and return an instance of the PropertyDetail. The instance will have its values set from the configuration service.

Specified by:
getPropertyHolder in interface ConfigurationService
Parameters:
context - The context we'll use to locate the property values and PropertyDetail
categoryId - A dot '.' separated list that will be used to lookup values in a property object.
Returns:
An object that will have the property values set - Property Detail
Throws:
ConfigurationException
See Also:
setValues( java.lang.String, java.lang.Object)

getCategoryId

public java.lang.String getCategoryId(PropertySource source)
Categories are identified by the full name of the property source object.

Specified by:
getCategoryId in interface ConfigurationService
Parameters:
source -
Returns:
The CategoryId value

isCachingDetail

protected boolean isCachingDetail()
Returns:
The CachingDetail value

getOrCreateDetail

protected java.lang.Object getOrCreateDetail(PropertySource context,
                                             java.lang.String categoryId)
                                      throws ConfigurationException
Either find the existing detail object, or create a new instance if an exsting one is not found.

Parameters:
context - The object that will want this property information.
categoryId - The id that should uniquely identify the desired properties.
Returns:
An object that will have all of its declared fields set to values.
Throws:
ConfigurationException

getPackageName

protected java.lang.String getPackageName(java.lang.String className)
Get the 'package name' from the class full name.

Parameters:
className -
Returns:
String of containing just the package name of the class.

findValueToSet

public java.lang.String findValueToSet(java.lang.String name,
                                       java.util.Properties props,
                                       java.lang.String categoryId)
In the following example assume an attributeName of 'host' and a categoryId of 'com.objectwave.configuration.MyClass'. For each attribute the system properties will be searched as follows: com.objectwave.configuration.MyClass.host com.objectwave.configuration.host com.objectwave.host com.host Default.host

Parameters:
name - The attribute name.
props - The potential source of the property value.
categoryId - Likely the class name of the PropertySource instance
Returns:
Find the property value that is to be set for a given property from the props parameter.

initialize

protected void initialize()
Instantiate the object that will allow me to call the setMethods.