Element eDefaultMailService = getDefaultParms().getChild(MAIL_SERVICE_CONFIG);
if (eDefaultMailService != null) {
MailServiceConfig mcf = new MailServiceConfig();
mcf.init(eDefaultMailService);
try {
setMailService(new MailService(mcf));
}
catch (Exception e) {
logger.fatal("Error configuring MailService. Exception: " + e.getMessage(), e);
throw new EnterpriseConfigurationObjectException(e.getMessage(), e);
}
}
// Add all attributes as 'Properties'
try {
java.util.List attrs = configElement.getAttributes();
for (int i=0; i<attrs.size(); i++) {
Attribute attr = (Attribute)attrs.get(i);
String key = attr.getName();
String value = attr.getValue();
logger.debug("ScheduleConfig, Adding " + key + " - " + value);
addProperty(key, value);
}
// Now the Elements.
java.util.List props = configElement.getChildren();
for (int i=0; i<props.size(); i++) {
Element aProp = (Element)props.get(i);
if (aProp.getName().equals("Commands")) {
java.util.List defaultAttrs = aProp.getAttributes();
java.util.List commandElements = aProp.getChildren();
ArrayList commands = new ArrayList();
Element eDefaultParms = new Element("DefaultParms");
// Add default attributes
for (int l=0; l<defaultAttrs.size(); l++) {
org.jdom.Attribute anAttr = (org.jdom.Attribute)defaultAttrs.get(l);
eDefaultParms.setAttribute((org.jdom.Attribute)anAttr.clone());
}
// Add default elements
for (int k=0; k<commandElements.size(); k++) {
Element eElem = (Element)commandElements.get(k);
if (eElem.getName().equals("Command")) {
commands.add(eElem);
}
else {
eDefaultParms.addContent((Element)eElem.clone());
}
}
// Instantiate and add a CommandConfig object for each Command element.
// ...
for (int j=0; j<commands.size(); j++) {
Element eCommand = (Element)commands.get(j);
CommandConfig aCommandConfig = new CommandConfig();
aCommandConfig.setAppName(getAppName());
aCommandConfig.setDefaultParms(eDefaultParms);
aCommandConfig.init(eCommand);
String commandType = aCommandConfig.getType();
String commandClass = aCommandConfig.getClassName();
String commandName = aCommandConfig.getName();
String key = "";
addProperty(commandName, commandClass);
addCommandConfig(aCommandConfig.getName(), aCommandConfig);
}
}
else if (aProp.getName().equals(RUN_TIME)) {
// override any defaults and add the Runtimes specific to this Schedule.
if (getScheduleRuntimes() != null) {
getScheduleRuntimes().removeAll(getScheduleRuntimes());
}
addRuntimes(aProp);
}
else if (aProp.getName().equals(MAIL_SERVICE_CONFIG)) {
setMailService(null);
MailServiceConfig mcf = new MailServiceConfig();
mcf.init(aProp);
setMailService(new MailService(mcf));
}
else {
String key = aProp.getName();
String value = aProp.getText();
logger.debug("Adding " + key + " - " + value);