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