Class Configurator
- java.lang.Object
- 
- 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 (or the full classname for classes outside the org.powertac hierarchy), class is the classname (but the first character is lowercase), instance is an optional instance name, and property is the property name. The target property must be annotated withConfigurableValue, either on the property itself, or on a setter method. For example, the following property will set the jmsBrokerUrl property of the class JmsManagementService.server.jmsManagementService.jmsBrokerUrl = tcp://localhost:61616In 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. There are many examples of configuration settings in the server properties file. When used in a broker, classes outside the org.powertac tree can be used if the full package prefix is specified. For example, the following property specification will set the foo property of class edu.umn.Bar: edu.umn.bar.foo = 42- Author:
- John Collins
 
- 
- 
Constructor SummaryConstructors Constructor Description Configurator()
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<?>configureInstances(Class<?> type)Creates and configures instances of the given class.Collection<?>configureNamedInstances(List<?> instances)Configures a set of instances of some class.voidconfigureSingleton(Object thing)Configures the given thing, using the pre-loaded Configuration.voidgatherBootstrapList(List<Object> things, ConfigurationRecorder recorder)Pulls "bootstrapState" ConfigurationValues out of objects in the given list, adds them to config with their names.voidgatherBootstrapState(Object thing, ConfigurationRecorder recorder)Pulls the "bootstrapState" ConfigurableValues out of object thing, adds them to config.voidgatherPublishedConfiguration(Object thing, ConfigurationRecorder recorder)Pulls the "published" ConfigurableValues out of object thing, adds them to config.static org.apache.commons.configuration2.PropertiesConfigurationreadProperties(File file)static org.apache.commons.configuration2.PropertiesConfigurationreadProperties(String path)static org.apache.commons.configuration2.PropertiesConfigurationreadProperties(URL url)static org.apache.commons.configuration2.XMLConfigurationreadXML(File file)static org.apache.commons.configuration2.XMLConfigurationreadXML(String path)static org.apache.commons.configuration2.XMLConfigurationreadXML(URL url)voidsetConfigOutput(ConfigurationRecorder configOutput)Sets up an output stream for config dump.voidsetConfiguration(org.apache.commons.configuration2.AbstractConfiguration config)Loads a Configuration into this Configurator.
 
- 
- 
- 
Method Detail- 
readXMLpublic static final org.apache.commons.configuration2.XMLConfiguration readXML(String path) throws org.apache.commons.configuration2.ex.ConfigurationException - Throws:
- org.apache.commons.configuration2.ex.ConfigurationException
 
 - 
readXMLpublic static final org.apache.commons.configuration2.XMLConfiguration readXML(File file) throws org.apache.commons.configuration2.ex.ConfigurationException - Throws:
- org.apache.commons.configuration2.ex.ConfigurationException
 
 - 
readXMLpublic static final org.apache.commons.configuration2.XMLConfiguration readXML(URL url) throws org.apache.commons.configuration2.ex.ConfigurationException - Throws:
- org.apache.commons.configuration2.ex.ConfigurationException
 
 - 
readPropertiespublic static final org.apache.commons.configuration2.PropertiesConfiguration readProperties(String path) throws org.apache.commons.configuration2.ex.ConfigurationException - Throws:
- org.apache.commons.configuration2.ex.ConfigurationException
 
 - 
readPropertiespublic static final org.apache.commons.configuration2.PropertiesConfiguration readProperties(URL url) throws org.apache.commons.configuration2.ex.ConfigurationException - Throws:
- org.apache.commons.configuration2.ex.ConfigurationException
 
 - 
readPropertiespublic static final org.apache.commons.configuration2.PropertiesConfiguration readProperties(File file) throws org.apache.commons.configuration2.ex.ConfigurationException - Throws:
- org.apache.commons.configuration2.ex.ConfigurationException
 
 - 
setConfigurationpublic void setConfiguration(org.apache.commons.configuration2.AbstractConfiguration config) Loads a Configuration into this Configurator.
 - 
setConfigOutputpublic void setConfigOutput(ConfigurationRecorder configOutput) Sets up an output stream for config dump.
 - 
configureSingletonpublic void configureSingleton(Object thing) Configures the given thing, using the pre-loaded Configuration.
 - 
configureInstancespublic 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 empty list in case instances cannot be created.
 - 
configureNamedInstancespublic Collection<?> configureNamedInstances(List<?> instances) Configures a set of instances of some class. In the configuration, we expect to see properties of the form pkg.class.name.property = value where name is the name of an instance in the list to be configured. These names must be accessible through a getName() method on each instance. It is an error if instances are not of the same class; in fact, the class of the first instance in the list is used to form the pkg.class. It also does not work for types that lack a getName() method returning a String, or if the name does not match the name in the properties. portion of the property names.
 - 
gatherPublishedConfigurationpublic void gatherPublishedConfiguration(Object thing, ConfigurationRecorder recorder) Pulls the "published" ConfigurableValues out of object thing, adds them to config.
 - 
gatherBootstrapStatepublic void gatherBootstrapState(Object thing, ConfigurationRecorder recorder) Pulls the "bootstrapState" ConfigurableValues out of object thing, adds them to config.
 - 
gatherBootstrapListpublic void gatherBootstrapList(List<Object> things, ConfigurationRecorder recorder) Pulls "bootstrapState" ConfigurationValues out of objects in the given list, adds them to config with their names. This requires that the instances in the list each have a getName() method that returns a String. Any instance lacking such a method will not be recorded, and an error message logged.
 
- 
 
-