}
public final Element getConfigElementByAttributeValue(String value, String attributeName) {
// Find the element "name" in the current document that matches the type
// of "configType"
Element root = getConfigDoc().getRootElement();
// Get all MessagingComponents.
// For each component, get its configuration Element.
// For each configuration element, check its type.
// If its type matches the type of this object, get the name associated to the configuration element.
// If the name matches this object's name, then return that element.
logger.debug("Looking for value: " + value);
logger.debug("Looking for attribute named: " + attributeName);
// java.util.List mComponents = root.getChild("MessagingComponents").getChildren();
java.util.List mComponents = root.getChildren();
for (int i=0; i<mComponents.size(); i++) {
Element e = (Element)mComponents.get(i);
java.util.List mComponentItems = e.getChildren();
for (int h=0; h<mComponentItems.size(); h++) {
Element eMComponent = (Element)mComponentItems.get(h);
Element eConfig = eMComponent.getChild("Configuration");
java.util.List lConfigs = eConfig.getChildren();
for (int j=0; j<lConfigs.size(); j++) {
Element eConfigGroup = (Element)lConfigs.get(j);
java.util.List lConfigItems = eConfigGroup.getChildren();
for (int k=0; k<lConfigItems.size(); k++) {
Element eConfigItem = (Element)lConfigItems.get(k);
if (eConfigItem.getName().equals(getType())) {
if (eConfigItem.getAttribute(attributeName).getValue().equals(getName())) {
// we have winner!
return eConfigItem;
}
}
else {
// Here's where we need to go all the way down for each configuration item
// and see if it contains a config object matching the one we're looking for.
Element e1 = matchConfigByAttribute(eConfigItem, attributeName);
if (e1 != null) {
if (e1.getName().equals(getType())) {
if (e1.getAttribute(attributeName).getValue().equals(getName())) {
// we have winner!
return e1;
}
}
}