01: /*
02: * Copyright 2006 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.soap.server.endpoint.mapping;
18:
19: import org.springframework.beans.factory.InitializingBean;
20: import org.springframework.util.Assert;
21: import org.springframework.ws.context.MessageContext;
22: import org.springframework.ws.server.EndpointInvocationChain;
23: import org.springframework.ws.server.EndpointMapping;
24: import org.springframework.ws.soap.server.SoapEndpointInvocationChain;
25: import org.springframework.ws.soap.server.SoapEndpointMapping;
26:
27: /**
28: * <code>EndpointMapping</code> implement that adds SOAP actors or roles to a delegate endpoint. Delegates to another
29: * <code>EndpointMapping</code>, set by <code>delegate</code>, and adds the actors or roles specified by
30: * <code>actorsOrRoles</code>.
31: * <p/>
32: * This endpoint mapping makes it possible to set actors/roles on a specific endpoint, without making the all endpoint
33: * mappings depend on SOAP-specific functionality. For normal use, setting an actor or role on an endpoint is not
34: * required, the default 'next' role is sufficient.
35: * <p/>
36: * It is only in a scenario when a certain endpoint act as a SOAP intermediary for another endpoint, as described in the
37: * SOAP specificication, this mapping is useful.
38: *
39: * @author Arjen Poutsma
40: * @see org.springframework.ws.soap.SoapHeader#examineMustUnderstandHeaderElements(String)
41: * @see org.springframework.ws.soap.SoapVersion#getNextActorOrRoleUri()
42: * @since 1.0.0
43: */
44: public class DelegatingSoapEndpointMapping implements InitializingBean,
45: SoapEndpointMapping {
46:
47: private EndpointMapping delegate;
48:
49: private String[] actorsOrRoles;
50:
51: private boolean isUltimateReceiver = true;
52:
53: /** Sets the delegate <code>EndpointMapping</code> to resolve the endpoint with. */
54: public void setDelegate(EndpointMapping delegate) {
55: this .delegate = delegate;
56: }
57:
58: public final void setActorOrRole(String actorOrRole) {
59: Assert.notNull(actorOrRole, "actorOrRole must not be null");
60: actorsOrRoles = new String[] { actorOrRole };
61: }
62:
63: public final void setActorsOrRoles(String[] actorsOrRoles) {
64: Assert.notEmpty(actorsOrRoles,
65: "actorsOrRoles must not be empty");
66: this .actorsOrRoles = actorsOrRoles;
67: }
68:
69: public final void setUltimateReceiver(boolean ultimateReceiver) {
70: isUltimateReceiver = ultimateReceiver;
71: }
72:
73: /**
74: * Creates a new <code>SoapEndpointInvocationChain</code> based on the delegate endpoint, the delegate interceptors,
75: * and set actors/roles.
76: *
77: * @see #setActorsOrRoles(String[])
78: */
79: public EndpointInvocationChain getEndpoint(
80: MessageContext messageContext) throws Exception {
81: EndpointInvocationChain delegateChain = delegate
82: .getEndpoint(messageContext);
83: return new SoapEndpointInvocationChain(delegateChain
84: .getEndpoint(), delegateChain.getInterceptors(),
85: actorsOrRoles, isUltimateReceiver);
86: }
87:
88: public void afterPropertiesSet() throws Exception {
89: Assert.notNull(delegate, "delegate is required");
90: }
91: }
|