1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.soap.server.endpoint;
18
19 import javax.xml.namespace.QName;
20
21 import org.springframework.util.StringUtils;
22 import org.springframework.ws.soap.server.endpoint.annotation.FaultCode;
23 import org.springframework.ws.soap.server.endpoint.annotation.SoapFault;
24
25
26
27
28
29
30
31
32 public class SoapFaultAnnotationExceptionResolver extends AbstractSoapFaultDefinitionExceptionResolver {
33
34 protected final SoapFaultDefinition getFaultDefinition(Object endpoint, Exception ex) {
35 SoapFault faultAnnotation = ex.getClass().getAnnotation(SoapFault.class);
36 if (faultAnnotation != null) {
37 SoapFaultDefinition definition = new SoapFaultDefinition();
38 if (faultAnnotation.faultCode() != FaultCode.CUSTOM) {
39 definition.setFaultCode(faultAnnotation.faultCode().value());
40 }
41 else if (StringUtils.hasLength(faultAnnotation.customFaultCode())) {
42 definition.setFaultCode(QName.valueOf(faultAnnotation.customFaultCode()));
43 }
44 definition.setFaultStringOrReason(faultAnnotation.faultStringOrReason());
45 definition.setLocale(StringUtils.parseLocaleString(faultAnnotation.locale()));
46 return definition;
47 }
48 else {
49 return null;
50 }
51 }
52 }