001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.hello_world_soap_http;
019:
020: import java.util.HashMap;
021: import java.util.Map;
022: import java.util.logging.Logger;
023: import javax.annotation.Resource;
024: import javax.jws.HandlerChain;
025: import javax.jws.Oneway;
026: import javax.jws.WebMethod;
027: import javax.jws.WebResult;
028: import javax.xml.ws.RequestWrapper;
029: import javax.xml.ws.ResponseWrapper;
030: import javax.xml.ws.WebServiceContext;
031:
032: @javax.jws.WebService(name="Greeter",serviceName="SOAPService",targetNamespace="http://apache.org/hello_world_soap_http")
033: @HandlerChain(name="TestHandlerChain",file="handlers.xml")
034: public class AnnotatedGreeterNoOverloadImpl {
035:
036: private static final Logger LOG = Logger
037: .getLogger(AnnotatedGreeterImpl.class.getName());
038:
039: @Resource
040: private int foo;
041:
042: private WebServiceContext context;
043:
044: private final Map<String, Integer> invocationCount = new HashMap<String, Integer>();
045:
046: public AnnotatedGreeterNoOverloadImpl() {
047: invocationCount.put("sayHi", 0);
048: invocationCount.put("greetMe", 0);
049: invocationCount.put("overloadedSayHi", 0);
050: }
051:
052: public int getInvocationCount(String method) {
053: if (invocationCount.containsKey(method)) {
054: return invocationCount.get(method).intValue();
055: } else {
056: System.out.println("No invocation count for method: "
057: + method);
058: return 0;
059: }
060: }
061:
062: @WebMethod
063: @WebResult(name="responseType",targetNamespace="http://apache.org/hello_world_soap_http/types")
064: @RequestWrapper(className="org.apache.hello_world_soap_http.types.SayHi",localName="sayHi",targetNamespace="http://apache.org/hello_world_soap_http/types")
065: @ResponseWrapper(className="org.apache.hello_world_soap_http.types.SayHiResponse",localName="sayHiResponse",targetNamespace="http://apache.org/hello_world_soap_http/types")
066: public String sayHi() {
067: incrementInvocationCount("sayHi");
068: return "Hi";
069: }
070:
071: @WebMethod
072: @WebResult(name="responseType",targetNamespace="http://apache.org/hello_world_soap_http/types")
073: @RequestWrapper(className="org.apache.hello_world_soap_http.types.GreetMe",localName="greetMe",targetNamespace="http://apache.org/hello_world_soap_http/types")
074: @ResponseWrapper(className="org.apache.hello_world_soap_http.types.GreetMeResponse",localName="greetMeResponse",targetNamespace="http://apache.org/hello_world_soap_http/types")
075: public String greetMe(String me) {
076: incrementInvocationCount("greetMe");
077: return "Bonjour " + me + "!";
078: }
079:
080: @WebMethod
081: @RequestWrapper(className="org.apache.hello_world_soap_http.types.GreetMeOneWay",localName="greetMeOneWay",targetNamespace="http://apache.org/hello_world_soap_http/types")
082: @Oneway
083: public void greetMeOneWay(String me) {
084: incrementInvocationCount("greetMeOneWay");
085: System.out.println("Hello there " + me);
086: System.out.println("That was OneWay to say hello");
087: }
088:
089: public void testDocLitFault(String faultType)
090: throws BadRecordLitFault, NoSuchCodeLitFault {
091: }
092:
093: @Resource
094: public void setContext(WebServiceContext ctx) {
095: context = ctx;
096: }
097:
098: public WebServiceContext getContext() {
099: return context;
100: }
101:
102: /**
103: * stop eclipse from whinging
104: */
105: public int getFoo() {
106: return foo;
107: }
108:
109: private void incrementInvocationCount(String method) {
110: LOG.info("Executing " + method);
111: int n = invocationCount.get(method);
112: invocationCount.put(method, n + 1);
113: }
114:
115: }
|