KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.objectweb.hello_world_soap_http;
2
3
4 import java.util.HashMap JavaDoc;
5 import java.util.Map JavaDoc;
6 import java.util.logging.Logger JavaDoc;
7 import javax.annotation.Resource;
8 import javax.jws.HandlerChain;
9 import javax.jws.Oneway;
10 import javax.jws.WebMethod;
11 import javax.jws.WebResult;
12 import javax.xml.ws.RequestWrapper;
13 import javax.xml.ws.ResponseWrapper;
14 import javax.xml.ws.WebServiceContext;
15
16 @javax.jws.WebService(name = "Greeter", serviceName = "SOAPService",
17                       targetNamespace = "http://objectweb.org/hello_world_soap_http")
18 @HandlerChain(name = "TestHandlerChain", file = "handlers.xml")
19 public class AnnotatedGreeterNoOverloadImpl {
20
21     private static final Logger JavaDoc LOG =
22         Logger.getLogger(AnnotatedGreeterImpl.class.getName());
23
24     @Resource
25     private int foo;
26
27     private WebServiceContext context;
28
29     private final Map JavaDoc<String JavaDoc, Integer JavaDoc> invocationCount = new HashMap JavaDoc<String JavaDoc, Integer JavaDoc>();
30
31     public AnnotatedGreeterNoOverloadImpl() {
32         invocationCount.put("sayHi", 0);
33         invocationCount.put("greetMe", 0);
34         invocationCount.put("overloadedSayHi", 0);
35     }
36
37     public int getInvocationCount(String JavaDoc method) {
38         if (invocationCount.containsKey(method)) {
39             return invocationCount.get(method).intValue();
40         } else {
41             System.out.println("No invocation count for method: " + method);
42             return 0;
43         }
44     }
45
46     @WebMethod
47     @WebResult(name = "responseType",
48                targetNamespace = "http://objectweb.org/hello_world_soap_http/types")
49     @RequestWrapper(className = "org.objectweb.hello_world_soap_http.types.SayHi",
50                     localName = "sayHi",
51                     targetNamespace = "http://objectweb.org/hello_world_soap_http/types")
52     @ResponseWrapper(className = "org.objectweb.hello_world_soap_http.types.SayHiResponse",
53                      localName = "sayHiResponse",
54                      targetNamespace = "http://objectweb.org/hello_world_soap_http/types")
55     public String JavaDoc sayHi() {
56         incrementInvocationCount("sayHi");
57         return "Hi";
58     }
59
60     @WebMethod
61     @WebResult(name = "responseType",
62                targetNamespace = "http://objectweb.org/hello_world_soap_http/types")
63     @RequestWrapper(className = "org.objectweb.hello_world_soap_http.types.GreetMe",
64                     localName = "greetMe",
65                     targetNamespace = "http://objectweb.org/hello_world_soap_http/types")
66     @ResponseWrapper(className = "org.objectweb.hello_world_soap_http.types.GreetMeResponse",
67                      localName = "greetMeResponse",
68                      targetNamespace = "http://objectweb.org/hello_world_soap_http/types")
69     public String JavaDoc greetMe(String JavaDoc me) {
70         incrementInvocationCount("greetMe");
71         return "Bonjour " + me + "!";
72     }
73     
74     @WebMethod
75     @RequestWrapper(className = "org.objectweb.hello_world_soap_http.types.GreetMeOneWay",
76                     localName = "greetMeOneWay",
77                     targetNamespace = "http://objectweb.org/hello_world_soap_http/types")
78     @Oneway
79     public void greetMeOneWay(String JavaDoc me) {
80         incrementInvocationCount("greetMeOneWay");
81         System.out.println("Hello there " + me);
82         System.out.println("That was OneWay to say hello");
83     }
84
85     public void testDocLitFault(String JavaDoc faultType) throws BadRecordLitFault, NoSuchCodeLitFault {
86     }
87
88     @Resource
89     public void setContext(WebServiceContext ctx) {
90         context = ctx;
91     }
92
93     public WebServiceContext getContext() {
94         return context;
95     }
96
97     /**
98      * stop eclipse from whinging
99      */

100     public int getFoo() {
101         return foo;
102     }
103     
104     private void incrementInvocationCount(String JavaDoc method) {
105         LOG.info("Executing " + method);
106         int n = invocationCount.get(method);
107         invocationCount.put(method, n + 1);
108     }
109
110 }
111
Popular Tags