001: package org.objectweb.celtix.common.annotation;
002:
003: import java.util.HashMap;
004: import java.util.Map;
005: import java.util.logging.Logger;
006: import javax.annotation.Resource;
007: import javax.jws.HandlerChain;
008: import javax.jws.WebMethod;
009: import javax.jws.WebResult;
010: import javax.xml.ws.RequestWrapper;
011: import javax.xml.ws.ResponseWrapper;
012: import javax.xml.ws.WebServiceContext;
013:
014: @javax.jws.WebService(name="Greeter",serviceName="SOAPService",targetNamespace="http://objectweb.org/hello_world_soap_http")
015: @HandlerChain(name="TestHandlerChain",file="handlers.xml")
016: public class AnnotatedGreeterImpl {
017:
018: private static final Logger LOG = Logger
019: .getLogger(AnnotatedGreeterImpl.class.getName());
020:
021: @Resource
022: private int foo;
023:
024: private WebServiceContext context;
025:
026: private final Map<String, Integer> invocationCount = new HashMap<String, Integer>();
027:
028: public AnnotatedGreeterImpl() {
029: invocationCount.put("sayHi", 0);
030: invocationCount.put("greetMe", 0);
031: invocationCount.put("overloadedSayHi", 0);
032: }
033:
034: public int getInvocationCount(String method) {
035: if (invocationCount.containsKey(method)) {
036: return invocationCount.get(method).intValue();
037: } else {
038: System.out.println("No invocation count for method: "
039: + method);
040: return 0;
041: }
042: }
043:
044: /**
045: * overloaded method - present for test purposes
046: */
047: @WebMethod(operationName="sayHiOverloaded")
048: @WebResult(name="responseType2",targetNamespace="http://objectweb.org/hello_world_soap_http/types")
049: @RequestWrapper(className="org.objectweb.hello_world_soap_http.types.SayHi2",localName="sayHi2",targetNamespace="http://objectweb.org/hello_world_soap_http/types")
050: @ResponseWrapper(className="org.objectweb.hello_world_soap_http.types.SayHiResponse2",localName="sayHiResponse2",targetNamespace="http://objectweb.org/hello_world_soap_http/types")
051: public String sayHi(String me) {
052: incrementInvocationCount("overloadedSayHi");
053: return "Hi " + me + "!";
054: }
055:
056: @WebMethod
057: @WebResult(name="responseType",targetNamespace="http://objectweb.org/hello_world_soap_http/types")
058: @RequestWrapper(className="org.objectweb.hello_world_soap_http.types.SayHi",localName="sayHi",targetNamespace="http://objectweb.org/hello_world_soap_http/types")
059: @ResponseWrapper(className="org.objectweb.hello_world_soap_http.types.SayHiResponse",localName="sayHiResponse",targetNamespace="http://objectweb.org/hello_world_soap_http/types")
060: public String sayHi() {
061: incrementInvocationCount("sayHi");
062: return "Hi";
063: }
064:
065: @WebMethod
066: @WebResult(name="responseType",targetNamespace="http://objectweb.org/hello_world_soap_http/types")
067: @RequestWrapper(className="org.objectweb.hello_world_soap_http.types.GreetMe",localName="greetMe",targetNamespace="http://objectweb.org/hello_world_soap_http/types")
068: @ResponseWrapper(className="org.objectweb.hello_world_soap_http.types.GreetMeResponse",localName="greetMeResponse",targetNamespace="http://objectweb.org/hello_world_soap_http/types")
069: public String greetMe(String me) {
070: incrementInvocationCount("greetMe");
071: return "Bonjour " + me + "!";
072: }
073:
074: @WebMethod
075: @RequestWrapper(className="org.objectweb.hello_world_soap_http.types.GreetMeOneWay",localName="greetMeOneWay",targetNamespace="http://objectweb.org/hello_world_soap_http/types")
076: public void greetMeOneWay(String me) {
077: incrementInvocationCount("greetMeOneWay");
078: System.out.println("Hello there " + me);
079: System.out.println("That was OneWay to say hello");
080: }
081:
082: public void testDocLitFault(String faultType) {
083: }
084:
085: @Resource
086: public void setContext(WebServiceContext ctx) {
087: context = ctx;
088: }
089:
090: public WebServiceContext getContext() {
091: return context;
092: }
093:
094: /**
095: * stop eclipse from whinging
096: */
097: public int getFoo() {
098: return foo;
099: }
100:
101: private void incrementInvocationCount(String method) {
102: LOG.info("Executing " + method);
103: int n = invocationCount.get(method);
104: invocationCount.put(method, n + 1);
105: }
106:
107: }
|