1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.oxm.config;
18
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.support.ManagedList;
24 import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
25 import org.springframework.beans.factory.xml.ParserContext;
26 import org.springframework.util.StringUtils;
27 import org.springframework.util.xml.DomUtils;
28 import org.w3c.dom.Element;
29
30
31
32
33
34
35
36 class Jaxb2MarshallerBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
37
38 private static final String JAXB2_MARSHALLER_CLASS_NAME = "org.springframework.oxm.jaxb.Jaxb2Marshaller";
39
40 protected String getBeanClassName(Element element) {
41 return JAXB2_MARSHALLER_CLASS_NAME;
42 }
43
44 protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
45 String contextPath = element.getAttribute("contextPath");
46 if (StringUtils.hasText(contextPath)) {
47 beanDefinitionBuilder.addPropertyValue("contextPath", contextPath);
48 }
49 List classes = DomUtils.getChildElementsByTagName(element, "class-to-be-bound");
50 if (!classes.isEmpty()) {
51 ManagedList classesToBeBound = new ManagedList(classes.size());
52 for (Iterator iterator = classes.iterator(); iterator.hasNext();) {
53 Element classToBeBound = (Element) iterator.next();
54 String className = classToBeBound.getAttribute("name");
55 classesToBeBound.add(className);
56 }
57 beanDefinitionBuilder.addPropertyValue("classesToBeBound", classesToBeBound);
58 }
59 }
60
61 }