1 17 package org.alfresco.config; 18 19 import java.util.List ; 20 21 import org.alfresco.config.evaluator.Evaluator; 22 import org.apache.commons.logging.Log; 23 import org.apache.commons.logging.LogFactory; 24 25 30 public class DefaultLookupAlgorithm implements ConfigLookupAlgorithm 31 { 32 private static final Log logger = LogFactory.getLog(DefaultLookupAlgorithm.class); 33 34 37 public void process(ConfigSection section, Evaluator evaluator, Object object, Config results) 38 { 39 if (evaluator.applies(object, section.getCondition())) 42 { 43 if (logger.isDebugEnabled()) 44 logger.debug(section + " matches"); 45 46 List <ConfigElement> sectionConfigElements = section.getConfigElements(); 47 for (ConfigElement newConfigElement : sectionConfigElements) 48 { 49 String name = newConfigElement.getName(); 51 ConfigElement existingConfigElement = (ConfigElement)results.getConfigElements().get(name); 52 if (existingConfigElement != null) 53 { 54 if (section.isReplace()) 55 { 56 results.getConfigElements().put(name, newConfigElement); 59 60 if (logger.isDebugEnabled()) 61 logger.debug("Replaced " + existingConfigElement + " with " + newConfigElement); 62 } 63 else 64 { 65 ConfigElement combinedConfigElement = existingConfigElement.combine(newConfigElement); 67 results.getConfigElements().put(name, combinedConfigElement); 68 69 if (logger.isDebugEnabled()) 70 { 71 logger.debug("Combined " + newConfigElement + " with " + existingConfigElement + 72 " to create " + combinedConfigElement); 73 } 74 } 75 } 76 else 77 { 78 results.getConfigElements().put(name, newConfigElement); 79 } 80 } 81 } 82 } 83 } 84 | Popular Tags |