1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.config;
18
19 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
20 import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
21 import org.springframework.beans.factory.xml.ParserContext;
22 import org.springframework.core.JdkVersion;
23 import org.springframework.util.ClassUtils;
24 import org.springframework.util.StringUtils;
25 import org.w3c.dom.Element;
26
27
28
29
30
31
32
33 class MarshallingEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
34
35 private static final String GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME =
36 "org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter";
37
38 private static final boolean genericAdapterPresent = ClassUtils.isPresent(GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME);
39
40 private static final String MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME =
41 "org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter";
42
43 protected boolean shouldGenerateIdAsFallback() {
44 return true;
45 }
46
47 protected String getBeanClassName(Element element) {
48 if (JdkVersion.isAtLeastJava15() && genericAdapterPresent) {
49 return GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME;
50 }
51 return MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME;
52 }
53
54 protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
55 String marshallerName = element.getAttribute("marshaller");
56 if (StringUtils.hasText(marshallerName)) {
57 beanDefinitionBuilder.addPropertyReference("marshaller", marshallerName);
58 }
59 String unmarshallerName = element.getAttribute("unmarshaller");
60 if (StringUtils.hasText(unmarshallerName)) {
61 beanDefinitionBuilder.addPropertyReference("unmarshaller", unmarshallerName);
62 }
63 }
64
65 }