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