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