1 16 package org.springframework.webflow.config; 17 18 import java.util.ArrayList ; 19 import java.util.Iterator ; 20 import java.util.List ; 21 22 import org.springframework.beans.factory.support.BeanDefinitionBuilder; 23 import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; 24 import org.springframework.beans.factory.xml.BeanDefinitionParser; 25 import org.springframework.util.StringUtils; 26 import org.springframework.util.xml.DomUtils; 27 import org.springframework.webflow.engine.builder.xml.XmlFlowRegistryFactoryBean; 28 import org.w3c.dom.Element ; 29 30 35 class RegistryBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { 36 37 39 private static final String LOCATION_ELEMENT = "location"; 40 41 43 private static final String FLOW_LOCATIONS_PROPERTY = "flowLocations"; 44 45 private static final String PATH_ATTRIBUTE = "path"; 46 47 protected Class getBeanClass(Element element) { 48 return XmlFlowRegistryFactoryBean.class; 49 } 50 51 protected void doParse(Element element, BeanDefinitionBuilder definitionBuilder) { 52 List locationElements = DomUtils.getChildElementsByTagName(element, LOCATION_ELEMENT); 53 List locations = getLocations(locationElements); 54 definitionBuilder.addPropertyValue(FLOW_LOCATIONS_PROPERTY, locations.toArray(new String [locations.size()])); 55 } 56 57 60 private List getLocations(List locationElements) { 61 List locations = new ArrayList (locationElements.size()); 62 for (Iterator i = locationElements.iterator(); i.hasNext();) { 63 Element locationElement = (Element )i.next(); 64 String path = locationElement.getAttribute(PATH_ATTRIBUTE); 65 if (StringUtils.hasText(path)) { 66 locations.add(path); 67 } 68 } 69 return locations; 70 } 71 } | Popular Tags |