1 16 17 package org.springframework.ejb.config; 18 19 import org.w3c.dom.Element ; 20 21 import org.springframework.beans.factory.config.RuntimeBeanReference; 22 import org.springframework.beans.factory.support.BeanDefinitionBuilder; 23 import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser; 24 import org.springframework.util.StringUtils; 25 import org.springframework.util.xml.DomUtils; 26 27 36 abstract class AbstractJndiLocatingBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser { 37 38 public static final String ENVIRONMENT = "environment"; 39 40 public static final String ENVIRONMENT_REF = "environment-ref"; 41 42 public static final String JNDI_ENVIRONMENT = "jndiEnvironment"; 43 44 45 protected boolean isEligibleAttribute(String attributeName) { 46 return (super.isEligibleAttribute(attributeName) && !ENVIRONMENT_REF.equals(attributeName)); 47 } 48 49 protected void postProcess(BeanDefinitionBuilder definitionBuilder, Element element) { 50 Object envValue = DomUtils.getChildElementValueByTagName(element, ENVIRONMENT); 51 if (envValue != null) { 52 definitionBuilder.addPropertyValue(JNDI_ENVIRONMENT, envValue); 54 } 55 else { 56 String envRef = element.getAttribute(ENVIRONMENT_REF); 58 if (StringUtils.hasLength(envRef)) { 59 definitionBuilder.addPropertyValue(JNDI_ENVIRONMENT, new RuntimeBeanReference(envRef)); 60 } 61 } 62 } 63 64 } 65 | Popular Tags |