View Javadoc

1   /*
2    * Copyright 2005-2010 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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.util.ClassUtils;
23  import org.springframework.util.StringUtils;
24  
25  import org.w3c.dom.Element;
26  
27  /**
28   * Parser for the <code>&lt;sws:marshalling-endpoints/&gt; element.
29   *
30   * @author Arjen Poutsma
31   * @since 1.5.0
32   * @deprecated as of Spring Web Services 2.0, in favor of [email protected] AnnotationDrivenBeanDefinitionParser}
33   */
34  @Deprecated
35  class MarshallingEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
36  
37      private static final String GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME =
38              "org.springframework.ws.server.endpoint.adapter.GenericMarshallingMethodEndpointAdapter";
39  
40      private static final boolean genericAdapterPresent =
41              ClassUtils.isPresent(GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME,
42                      MarshallingEndpointsBeanDefinitionParser.class.getClassLoader());
43  
44      private static final String MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME =
45              "org.springframework.ws.server.endpoint.adapter.MarshallingMethodEndpointAdapter";
46  
47      @Override
48      protected boolean shouldGenerateIdAsFallback() {
49          return true;
50      }
51  
52      @Override
53      protected String getBeanClassName(Element element) {
54          if (genericAdapterPresent) {
55                  return GENERIC_MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME;
56          }
57          return MARSHALLING_METHOD_ENDPOINT_ADAPTER_CLASS_NAME;
58      }
59  
60      @Override
61      protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
62          String marshallerName = element.getAttribute("marshaller");
63          if (StringUtils.hasText(marshallerName)) {
64              beanDefinitionBuilder.addPropertyReference("marshaller", marshallerName);
65          }
66          String unmarshallerName = element.getAttribute("unmarshaller");
67          if (StringUtils.hasText(unmarshallerName)) {
68              beanDefinitionBuilder.addPropertyReference("unmarshaller", unmarshallerName);
69          }
70      }
71  
72  }