1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.soap.server.endpoint.mapping;
18
19 import java.lang.reflect.Method;
20
21 import org.springframework.util.Assert;
22 import org.springframework.util.StringUtils;
23 import org.springframework.ws.context.MessageContext;
24 import org.springframework.ws.server.EndpointInterceptor;
25 import org.springframework.ws.server.EndpointInvocationChain;
26 import org.springframework.ws.server.endpoint.mapping.AbstractAnnotationMethodEndpointMapping;
27 import org.springframework.ws.soap.SoapMessage;
28 import org.springframework.ws.soap.server.SoapEndpointInvocationChain;
29 import org.springframework.ws.soap.server.SoapEndpointMapping;
30 import org.springframework.ws.soap.server.endpoint.annotation.SoapAction;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 public class SoapActionAnnotationMethodEndpointMapping extends AbstractAnnotationMethodEndpointMapping
51 implements SoapEndpointMapping {
52
53 private String[] actorsOrRoles;
54
55 private boolean isUltimateReceiver = true;
56
57 public final void setActorOrRole(String actorOrRole) {
58 Assert.notNull(actorOrRole, "actorOrRole must not be null");
59 actorsOrRoles = new String[]{actorOrRole};
60 }
61
62 public final void setActorsOrRoles(String[] actorsOrRoles) {
63 Assert.notEmpty(actorsOrRoles, "actorsOrRoles must not be empty");
64 this.actorsOrRoles = actorsOrRoles;
65 }
66
67 public final void setUltimateReceiver(boolean ultimateReceiver) {
68 isUltimateReceiver = ultimateReceiver;
69 }
70
71
72
73
74
75
76
77
78
79
80
81 protected final EndpointInvocationChain createEndpointInvocationChain(MessageContext messageContext,
82 Object endpoint,
83 EndpointInterceptor[] interceptors) {
84 return new SoapEndpointInvocationChain(endpoint, interceptors, actorsOrRoles, isUltimateReceiver);
85 }
86
87 protected String getLookupKeyForMessage(MessageContext messageContext) throws Exception {
88 if (messageContext.getRequest() instanceof SoapMessage) {
89 SoapMessage request = (SoapMessage) messageContext.getRequest();
90 String soapAction = request.getSoapAction();
91 if (StringUtils.hasLength(soapAction) && soapAction.charAt(0) == '"' &&
92 soapAction.charAt(soapAction.length() - 1) == '"') {
93 return soapAction.substring(1, soapAction.length() - 1);
94 }
95 else {
96 return soapAction;
97 }
98 }
99 else {
100 return null;
101 }
102 }
103
104 protected String getLookupKeyForMethod(Method method) {
105 SoapAction soapAction = method.getAnnotation(SoapAction.class);
106 return soapAction != null ? soapAction.value() : null;
107 }
108 }