KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > hello_world_soap_http > DerivedGreeterImpl


1 package org.objectweb.hello_world_soap_http;
2
3 import java.rmi.RemoteException JavaDoc;
4 import java.util.HashMap JavaDoc;
5 import java.util.Map JavaDoc;
6 import java.util.concurrent.Future JavaDoc;
7 import java.util.logging.Logger JavaDoc;
8
9 import javax.xml.ws.AsyncHandler;
10 import javax.xml.ws.Response;
11
12 import org.objectweb.hello_world_soap_http.types.BareDocumentResponse;
13 import org.objectweb.hello_world_soap_http.types.GreetMeResponse;
14 import org.objectweb.hello_world_soap_http.types.GreetMeSometimeResponse;
15 import org.objectweb.hello_world_soap_http.types.SayHiResponse;
16 import org.objectweb.hello_world_soap_http.types.TestDocLitFaultResponse;
17
18
19 @javax.jws.WebService(name = "Greeter", serviceName = "SOAPService",
20                       targetNamespace = "http://objectweb.org/hello_world_soap_http")
21 public class DerivedGreeterImpl implements Greeter {
22
23     private static final Logger JavaDoc LOG =
24         Logger.getLogger(DerivedGreeterImpl.class.getName());
25     private final Map JavaDoc<String JavaDoc, Integer JavaDoc> invocationCount = new HashMap JavaDoc<String JavaDoc, Integer JavaDoc>();
26
27     public DerivedGreeterImpl() {
28         invocationCount.put("sayHi", 0);
29         invocationCount.put("greetMe", 0);
30         invocationCount.put("greetMeOneWay", 0);
31         invocationCount.put("overloadedSayHi", 0);
32     }
33
34     public int getInvocationCount(String JavaDoc method) {
35         if (invocationCount.containsKey(method)) {
36             return invocationCount.get(method).intValue();
37         } else {
38             System.out.println("No invocation count for method: " + method);
39             return 0;
40         }
41     }
42
43     /**
44      * overloaded method - present for test purposes
45      */

46     public String JavaDoc sayHi(String JavaDoc me) throws RemoteException JavaDoc {
47         incrementInvocationCount("overloadedSayHi");
48         return "Hi " + me + "!";
49     }
50
51     @javax.jws.WebMethod(operationName = "sayHi")
52     /*
53      * @javax.jws.WebResult(name="responseType",
54      * targetNamespace="http://objectweb.org/hello_world_soap_http")
55      */

56     public String JavaDoc sayHi() {
57         incrementInvocationCount("sayHi");
58         return "Hi";
59     }
60
61     public void testDocLitFault(String JavaDoc faultType) throws BadRecordLitFault, NoSuchCodeLitFault {
62     }
63
64     public Response<TestDocLitFaultResponse> testDocLitFaultAsync(String JavaDoc faultType) {
65         return null;
66         /*not called */
67     }
68
69     public Response<TestDocLitFaultResponse> testDocLitFaultAsync(String JavaDoc faultType, AsyncHandler ah) {
70         return null;
71         /*not called */
72     }
73
74
75     public String JavaDoc greetMe(String JavaDoc me) {
76         incrementInvocationCount("greetMe");
77         return "Bonjour " + me + "!";
78     }
79
80     public String JavaDoc greetMeSometime(String JavaDoc me) {
81         incrementInvocationCount("greetMeSometime");
82         return "Hello there " + me + "!";
83     }
84
85     public Future JavaDoc<?> greetMeSometimeAsync(String JavaDoc requestType,
86                                            AsyncHandler<GreetMeSometimeResponse> asyncHandler) {
87         return null;
88         /* to be implemented */
89     }
90
91     public Response<GreetMeSometimeResponse> greetMeSometimeAsync(String JavaDoc requestType) {
92         return null;
93         /* to be implemented */
94     }
95
96     public Future JavaDoc<?> greetMeAsync(String JavaDoc requestType, AsyncHandler<GreetMeResponse> asyncHandler) {
97         return null;
98         /*not called */
99     }
100
101     public Response<GreetMeResponse> greetMeAsync(String JavaDoc requestType) {
102         return null;
103         /*not called */
104     }
105
106     public Future JavaDoc<?> sayHiAsync(AsyncHandler<SayHiResponse> asyncHandler) {
107         return null;
108         /*not called */
109     }
110
111     public Response<SayHiResponse> sayHiAsync() {
112         return null;
113         /*not called */
114     }
115
116     public Future JavaDoc<?> testDocLitBareAsync(String JavaDoc in, AsyncHandler<BareDocumentResponse> asyncHandler) {
117         return null;
118         /*not called */
119     }
120
121     public Response<BareDocumentResponse> testDocLitBareAsync(String JavaDoc in) {
122         return null;
123         /*not called */
124     }
125
126     public void greetMeOneWay(String JavaDoc me) {
127         incrementInvocationCount("greetMeOneWay");
128     }
129
130     public BareDocumentResponse testDocLitBare(String JavaDoc in) {
131         incrementInvocationCount("testDocLitBare");
132         BareDocumentResponse res = new BareDocumentResponse();
133         res.setCompany("Celtix");
134         res.setId(1);
135         return res;
136     }
137
138     private void incrementInvocationCount(String JavaDoc method) {
139         LOG.info("Executing " + method);
140         int n = invocationCount.get(method);
141         invocationCount.put(method, n + 1);
142     }
143
144 }
145
Popular Tags