private Map typeBuilderMap = new HashMap();
private Map validationRuleBuilderMap = new HashMap();
private ComponentManager componentManager;
public void configure(Configuration configuration) throws ConfigurationException {
LifecycleHelper lifecycleHelper = new LifecycleHelper(null, null, componentManager, null, null, null);
// read available datatypes from configuration
Configuration[] datatypeConfs = configuration.getChild("datatypes").getChildren("datatype");
if (datatypeConfs.length == 0)
getLogger().warn("No Woody datatypes found in DatatypeManager configuration.");
for (int i = 0; i < datatypeConfs.length; i++) {
String name = datatypeConfs[i].getAttribute("name");
String factoryClassName = datatypeConfs[i].getAttribute("factory");
Class clazz;
try {
clazz = Class.forName(factoryClassName);
} catch (Exception e) {
throw new ConfigurationException("Could not load class \"" + factoryClassName + "\" specified at " + datatypeConfs[i].getLocation(), e);
}
DatatypeBuilder datatypeBuilder;
try {
datatypeBuilder = (DatatypeBuilder)clazz.newInstance();
lifecycleHelper.setupComponent(datatypeBuilder);
} catch (Exception e) {
throw new ConfigurationException("Could not create DatatypeBuilder \"" + factoryClassName + "\"", e);
}
typeBuilderMap.put(name, datatypeBuilder);
}
// read available validation rules from configuration
Configuration[] validationRuleConfs = configuration.getChild("validation-rules").getChildren("validation-rule");
if (validationRuleConfs.length == 0)
getLogger().warn("No Woody validation rules found in DatatypeManager configuration");
for (int i = 0; i < validationRuleConfs.length; i++) {
String name = validationRuleConfs[i].getAttribute("name");
String factoryClassName = validationRuleConfs[i].getAttribute("factory");
Class clazz;
try {
clazz = Class.forName(factoryClassName);
} catch (Exception e) {
throw new ConfigurationException("Could not load class \"" + factoryClassName + "\" specified at " + validationRuleConfs[i].getLocation(), e);
}
ValidationRuleBuilder validationRuleBuilder;
try {
validationRuleBuilder = (ValidationRuleBuilder)clazz.newInstance();
lifecycleHelper.setupComponent(validationRuleBuilder);
} catch (Exception e) {
throw new ConfigurationException("Could not create ValidationRuleBuilder \"" + factoryClassName + "\"", e);
}
validationRuleBuilderMap.put(name, validationRuleBuilder);
}