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 java.util.List;
20  import java.util.Properties;
21  
22  import org.springframework.beans.factory.support.BeanDefinitionBuilder;
23  import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
24  import org.springframework.beans.factory.xml.ParserContext;
25  import org.springframework.util.xml.DomUtils;
26  
27  import org.w3c.dom.Element;
28  
29  /**
30   * Parser for the <code>&lt;sws:xpath-endpoints/&gt; element.
31   *
32   * @author Arjen Poutsma
33   * @since 1.5.0
34   * @deprecated as of Spring Web Services 2.0, in favor of [email protected] AnnotationDrivenBeanDefinitionParser}
35   */
36  @Deprecated
37  class XPathEndpointsBeanDefinitionParser extends AbstractSimpleBeanDefinitionParser {
38  
39      private static final String XPATH_PARAM_ANNOTATION_METHOD_ENDPOINT_ADAPTER_CLASS_NAME =
40              "org.springframework.ws.server.endpoint.adapter.XPathParamAnnotationMethodEndpointAdapter";
41  
42      @Override
43      protected boolean shouldGenerateIdAsFallback() {
44          return true;
45      }
46  
47      @Override
48      protected String getBeanClassName(Element element) {
49          return XPATH_PARAM_ANNOTATION_METHOD_ENDPOINT_ADAPTER_CLASS_NAME;
50      }
51  
52      @Override
53      protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder beanDefinitionBuilder) {
54          List<Element> namespaceElements = DomUtils.getChildElementsByTagName(element, "namespace");
55          if (!namespaceElements.isEmpty()) {
56              Properties namespaces = new Properties();
57              for (Element namespaceElement : namespaceElements) {
58                  String prefix = namespaceElement.getAttribute("prefix");
59                  String uri = namespaceElement.getAttribute("uri");
60                  namespaces.setProperty(prefix, uri);
61              }
62              beanDefinitionBuilder.addPropertyValue("namespaces", namespaces);
63          }
64      }
65  
66  }