org.powertac.common.config
Class Configurator

java.lang.Object
  extended by org.powertac.common.config.Configurator

public class Configurator
extends Object

Fills in configured values from configuration source based on annotations in the source code.

Configuration clauses are assumed to be of the form
    pkg.class[.instance].property = value
where pkg is the package name without org.powertac, class is the classname, instance is the optional instance name, and property is the property name.

In the server, an instance of this class is typically created by a service that collects configuration data, creates and initializes a Configurator, then waits for each service to ask for its configuration.

Author:
John Collins

Constructor Summary
Configurator()
           
 
Method Summary
 Collection<?> configureInstances(Class<?> type)
          Creates and configures instances of the given class.
 void configureSingleton(Object thing)
          Configures the given thing, using the pre-loaded Configuration.
 void gatherPublishedConfiguration(Object thing, ConfigurationRecorder recorder)
          Pulls the "published" ConfigurableValues out of object thing, adds them to config.
 void setConfiguration(org.apache.commons.configuration.Configuration config)
          Loads a Configuration into this Configurator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Configurator

public Configurator()
Method Detail

setConfiguration

public void setConfiguration(org.apache.commons.configuration.Configuration config)
Loads a Configuration into this Configurator.


configureSingleton

public void configureSingleton(Object thing)
Configures the given thing, using the pre-loaded Configuration.


configureInstances

public Collection<?> configureInstances(Class<?> type)
Creates and configures instances of the given class. In the configuration, we expect to see a property of the form pkg.class.instances = a, b, c, ... where a, b, c, etc. are the names of instances of the class to be created and configured. These names are provided to the instances through their constructors, and are expected to show up in the configuration as instance names in clauses of the form pkg.class.name.property = value. Returns null in case instances cannot be created.


gatherPublishedConfiguration

public void gatherPublishedConfiguration(Object thing,
                                         ConfigurationRecorder recorder)
Pulls the "published" ConfigurableValues out of object thing, adds them to config.



Copyright © 2012. All Rights Reserved.