protected Object fromXml ( String xml , String tagName ) throws Exception { Document document = XMLUtil . parseXMLFromString ( xml ) ; NodeList nodeList = document . getElementsByTagName ( tagName ) ; if ( nodeList == null || nodeList . getLength ( ) != 1 ) { throw new DOMException ( DOMException . NOT_FOUND_ERR , "Top level tag '" + tagName + "' was not found." ) ; } Element element = ( Element ) nodeList . item ( 0 ) ; Class < ? > beanClass = getBeanClass ( element ) ; BeanDefinitionBuilder builder = BeanDefinitionBuilder . rootBeanDefinition ( beanClass ) ; doParse ( element , builder ) ; DefaultListableBeanFactory factory = new DefaultListableBeanFactory ( ) ; factory . setParentBeanFactory ( SpringUtil . getAppContext ( ) ) ; AbstractBeanDefinition beanDefinition = builder . getBeanDefinition ( ) ; factory . registerBeanDefinition ( tagName , beanDefinition ) ; return factory . getBean ( tagName ) ; }
Parses an xml extension from an xml string .