Debian Codegraph @

test/jaxrpc/AAAHandler.java

raw
1 package test.jaxrpc;
2
3 import javax.xml.namespace.QName;
4 import javax.xml.rpc.handler.Handler;
5 import javax.xml.rpc.handler.HandlerInfo;
6 import javax.xml.rpc.handler.MessageContext;
7 import java.util.Map;
8
9 public class AAAHandler implements Handler {
10 private int handleRequestInvocations = 0;
11 private int handleResponseInvocations = 0;
12 private int handleFaultInvocations = 0;
13
14 public Object handleRequestReturnValue = null;
15 public Object handleResponseReturnValue = null;
16 public Object handleFaultReturnValue = null;
17
18 public boolean handleRequest(MessageContext context) {
19 handleRequestInvocations++;
20 return returnAppropriateValue(handleRequestReturnValue);
21 }
22
23 public boolean handleResponse(MessageContext context) {
24 handleResponseInvocations++;
25 return returnAppropriateValue(handleResponseReturnValue);
26 }
27
28 public boolean handleFault(MessageContext context) {
29 handleFaultInvocations++;
30 return returnAppropriateValue(handleFaultReturnValue);
31 }
32
33 private boolean returnAppropriateValue(Object returnValue) {
34 if (returnValue == null)
35 return true;
36 else if (returnValue instanceof Boolean)
37 return ((Boolean) returnValue).booleanValue();
38 else if (returnValue instanceof RuntimeException)
39 throw (RuntimeException) returnValue;
40 else {
41 throw new RuntimeException();
42 }
43 }
44
45 public void init(HandlerInfo config) {
46 Map map = config.getHandlerConfig();
47 handleRequestReturnValue = map.get("HANDLE_REQUEST_RETURN_VALUE");
48 handleResponseReturnValue = map.get("HANDLE_RESPONSE_RETURN_VALUE");
49 handleFaultReturnValue = map.get("HANDLE_FAULT_RETURN_VALUE");
50 }
51
52 public void destroy() {
53 }
54
55 public QName[] getHeaders() {
56 return new QName[0];
57 }
58
59 public int getHandleRequestInvocations() {
60 return handleRequestInvocations;
61 }
62
63 public int getHandleResponseInvocations() {
64 return handleResponseInvocations;
65 }
66
67 public int getHandleFaultInvocations() {
68 return handleFaultInvocations;
69 }
70
71 public Object getHandleRequestReturnValue() {
72 return handleRequestReturnValue;
73 }
74
75 public void setHandleRequestReturnValue(Object handleRequestReturnValue) {
76 this.handleRequestReturnValue = handleRequestReturnValue;
77 }
78
79 public Object getHandleResponseReturnValue() {
80 return handleResponseReturnValue;
81 }
82
83 public void setHandleResponseReturnValue(Object handleResponseReturnValue) {
84 this.handleResponseReturnValue = handleResponseReturnValue;
85 }
86
87 public Object getHandleFaultReturnValue() {
88 return handleFaultReturnValue;
89 }
90
91 public void setHandleFaultReturnValue(Object handleFaultReturnValue) {
92 this.handleFaultReturnValue = handleFaultReturnValue;
93 }
94
95 }