View Javadoc

1   /*
2    * Copyright 2005 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.server.endpoint.mapping;
18  
19  import javax.xml.namespace.QName;
20  import javax.xml.stream.XMLStreamException;
21  import javax.xml.transform.TransformerException;
22  import javax.xml.transform.TransformerFactory;
23  
24  import org.springframework.ws.context.MessageContext;
25  import org.springframework.ws.server.endpoint.support.PayloadRootUtils;
26  
27  /**
28   * Implementation of the <code>EndpointMapping</code> interface to map from the qualified name of the request payload
29   * root element. Supports both mapping to bean instances and mapping to bean names: the latter is required for prototype
30   * endpoints.
31   * <p/>
32   * The <code>endpointMap</code> property is suitable for populating the endpoint map with bean references, e.g. via the
33   * map element in XML bean definitions.
34   * <p/>
35   * Mappings to bean names can be set via the <code>mappings</code> property, in a form accepted by the
36   * <code>java.util.Properties</code> class, like as follows:
37   * <pre>
38   * {http://www.springframework.org/spring-ws/samples/airline/schemas}BookFlight=bookFlightEndpoint
39   * {http://www.springframework.org/spring-ws/samples/airline/schemas}GetFlights=getFlightsEndpoint
40   * </pre>
41   * The syntax is QNAME=ENDPOINT_BEAN_NAME. Qualified names are parsed using the syntax described in
42   * <code>QNameEditor</code>.
43   *
44   * @author Arjen Poutsma
45   * @see org.springframework.xml.namespace.QNameEditor
46   * @since 1.0.0
47   */
48  public class PayloadRootQNameEndpointMapping extends AbstractQNameEndpointMapping {
49  
50      private static TransformerFactory transformerFactory;
51  
52      static {
53          transformerFactory = TransformerFactory.newInstance();
54      }
55  
56      protected QName resolveQName(MessageContext messageContext) throws TransformerException, XMLStreamException {
57          return PayloadRootUtils.getPayloadRootQName(messageContext.getRequest().getPayloadSource(), transformerFactory);
58      }
59  
60  }