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.core.annotation.AnnotationUtils;
22 import org.springframework.util.Assert;
23 import org.springframework.util.StringUtils;
24 import org.springframework.ws.context.MessageContext;
25 import org.springframework.ws.server.EndpointInterceptor;
26 import org.springframework.ws.server.EndpointInvocationChain;
27 import org.springframework.ws.server.endpoint.mapping.AbstractAnnotationMethodEndpointMapping;
28 import org.springframework.ws.soap.SoapMessage;
29 import org.springframework.ws.soap.server.SoapEndpointInvocationChain;
30 import org.springframework.ws.soap.server.SoapEndpointMapping;
31 import org.springframework.ws.soap.server.endpoint.annotation.SoapAction;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 public class SoapActionAnnotationMethodEndpointMapping extends AbstractAnnotationMethodEndpointMapping<String>
52 implements SoapEndpointMapping {
53
54 private String[] actorsOrRoles;
55
56 private boolean isUltimateReceiver = true;
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, "actorsOrRoles must not be empty");
65 this.actorsOrRoles = actorsOrRoles;
66 }
67
68 public final void setUltimateReceiver(boolean ultimateReceiver) {
69 isUltimateReceiver = ultimateReceiver;
70 }
71
72
73
74
75
76
77
78
79
80
81
82 @Override
83 protected final EndpointInvocationChain createEndpointInvocationChain(MessageContext messageContext,
84 Object endpoint,
85 EndpointInterceptor[] interceptors) {
86 return new SoapEndpointInvocationChain(endpoint, interceptors, actorsOrRoles, isUltimateReceiver);
87 }
88
89 @Override
90 protected String getLookupKeyForMessage(MessageContext messageContext) throws Exception {
91 if (messageContext.getRequest() instanceof SoapMessage) {
92 SoapMessage request = (SoapMessage) messageContext.getRequest();
93 String soapAction = request.getSoapAction();
94 if (StringUtils.hasLength(soapAction) && soapAction.charAt(0) == '"' &&
95 soapAction.charAt(soapAction.length() - 1) == '"') {
96 return soapAction.substring(1, soapAction.length() - 1);
97 }
98 else {
99 return soapAction;
100 }
101 }
102 else {
103 return null;
104 }
105 }
106
107 @Override
108 protected String getLookupKeyForMethod(Method method) {
109 SoapAction soapAction = AnnotationUtils.findAnnotation(method, SoapAction.class);
110 return soapAction != null ? soapAction.value() : null;
111 }
112 }