1 16 package org.springframework.webflow.config; 17 18 import java.util.Iterator ; 19 import java.util.List ; 20 import java.util.Map ; 21 22 import org.springframework.beans.factory.config.RuntimeBeanReference; 23 import org.springframework.beans.factory.support.BeanDefinitionBuilder; 24 import org.springframework.beans.factory.support.ManagedMap; 25 import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser; 26 import org.springframework.beans.factory.xml.BeanDefinitionParser; 27 import org.springframework.util.xml.DomUtils; 28 import org.springframework.webflow.execution.factory.ConditionalFlowExecutionListenerLoader; 29 import org.w3c.dom.Element ; 30 31 37 class ExecutionListenersBeanDefinitionParser extends AbstractSingleBeanDefinitionParser { 38 39 41 private static final String LISTENER_ELEMENT= "listener"; 42 43 45 private static final String LISTENERS_PROPERTY = "listeners"; 46 47 private static final String CRITERIA_ATTRIBUTE = "criteria"; 48 49 private static final String REF_ATTRIBUTE = "ref"; 50 51 protected Class getBeanClass(Element element) { 52 return ConditionalFlowExecutionListenerLoader.class; 53 } 54 55 protected void doParse(Element element, BeanDefinitionBuilder definitionBuilder) { 56 List listenerElements = DomUtils.getChildElementsByTagName(element, LISTENER_ELEMENT); 57 definitionBuilder.addPropertyValue(LISTENERS_PROPERTY, getListenersWithCriteria(listenerElements)); 58 } 59 60 66 private Map getListenersWithCriteria(List listeners) { 67 Map listenersWithCriteria = new ManagedMap(listeners.size()); 68 for (Iterator i = listeners.iterator(); i.hasNext();) { 69 Element listenerElement = (Element )i.next(); 70 RuntimeBeanReference ref = new RuntimeBeanReference(listenerElement.getAttribute(REF_ATTRIBUTE)); 71 String criteria = listenerElement.getAttribute(CRITERIA_ATTRIBUTE); 72 listenersWithCriteria.put(ref, criteria); 73 } 74 return listenersWithCriteria; 75 } 76 } | Popular Tags |