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.rmi.RemoteException;
021: import java.util.HashMap;
022: import java.util.Map;
023: import java.util.concurrent.Future;
024: import java.util.logging.Logger;
025:
026: import javax.xml.ws.AsyncHandler;
027: import javax.xml.ws.Response;
028:
029: import org.apache.hello_world_soap_http.types.BareDocumentResponse;
030: import org.apache.hello_world_soap_http.types.GreetMeLaterResponse;
031: import org.apache.hello_world_soap_http.types.GreetMeResponse;
032: import org.apache.hello_world_soap_http.types.GreetMeSometimeResponse;
033: import org.apache.hello_world_soap_http.types.SayHiResponse;
034: import org.apache.hello_world_soap_http.types.TestDocLitFaultResponse;
035: import org.apache.hello_world_soap_http.types.TestNillableResponse;
036:
037: @javax.jws.WebService(name="Greeter",serviceName="SOAPService",targetNamespace="http://apache.org/hello_world_soap_http",wsdlLocation="tetutils/hello_world.wsdl")
038: public class DerivedGreeterImpl implements Greeter {
039:
040: private static final Logger LOG = Logger
041: .getLogger(DerivedGreeterImpl.class.getName());
042: private final Map<String, Integer> invocationCount = new HashMap<String, Integer>();
043:
044: public DerivedGreeterImpl() {
045: invocationCount.put("sayHi", 0);
046: invocationCount.put("greetMe", 0);
047: invocationCount.put("greetMeLater", 0);
048: invocationCount.put("greetMeOneWay", 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: /**
063: * overloaded method - present for test purposes
064: */
065: public String sayHi(String me) throws RemoteException {
066: incrementInvocationCount("overloadedSayHi");
067: return "Hi " + me + "!";
068: }
069:
070: @javax.jws.WebMethod(operationName="sayHi")
071: /*
072: * @javax.jws.WebResult(name="responseType",
073: * targetNamespace="http://apache.org/hello_world_soap_http")
074: */
075: public String sayHi() {
076: incrementInvocationCount("sayHi");
077: return "Hi";
078: }
079:
080: public void testDocLitFault(String faultType)
081: throws BadRecordLitFault, NoSuchCodeLitFault {
082: }
083:
084: public Response<TestDocLitFaultResponse> testDocLitFaultAsync(
085: String faultType) {
086: return null;
087: /*not called */
088: }
089:
090: public Response<TestDocLitFaultResponse> testDocLitFaultAsync(
091: String faultType, AsyncHandler<TestDocLitFaultResponse> ah) {
092: return null;
093: /*not called */
094: }
095:
096: public String greetMe(String me) {
097: incrementInvocationCount("greetMe");
098: return "Bonjour " + me + "!";
099: }
100:
101: public String greetMeLater(long delay) {
102: if (delay > 0) {
103: try {
104: Thread.sleep(delay);
105: } catch (InterruptedException ex) {
106: /// ignore
107: }
108: }
109: incrementInvocationCount("greetMeLater");
110: return "Hello, finally!";
111: }
112:
113: public String greetMeSometime(String me) {
114: incrementInvocationCount("greetMeSometime");
115: return "Hello there " + me + "!";
116: }
117:
118: public Future<?> greetMeSometimeAsync(String requestType,
119: AsyncHandler<GreetMeSometimeResponse> asyncHandler) {
120: return null;
121: /* to be implemented */
122: }
123:
124: public Response<GreetMeSometimeResponse> greetMeSometimeAsync(
125: String requestType) {
126: return null;
127: /* to be implemented */
128: }
129:
130: public Future<?> greetMeAsync(String requestType,
131: AsyncHandler<GreetMeResponse> asyncHandler) {
132: return null;
133: /*not called */
134: }
135:
136: public Response<GreetMeResponse> greetMeAsync(String requestType) {
137: return null;
138: /*not called */
139: }
140:
141: public Future<?> greetMeLaterAsync(long requestType,
142: AsyncHandler<GreetMeLaterResponse> asyncHandler) {
143: return null;
144: /*not called */
145: }
146:
147: public Response<GreetMeLaterResponse> greetMeLaterAsync(
148: long requestType) {
149: return null;
150: /*not called */
151: }
152:
153: public Future<?> sayHiAsync(AsyncHandler<SayHiResponse> asyncHandler) {
154: return null;
155: /*not called */
156: }
157:
158: public Response<SayHiResponse> sayHiAsync() {
159: return null;
160: /*not called */
161: }
162:
163: public Future<?> testDocLitBareAsync(String in,
164: AsyncHandler<BareDocumentResponse> asyncHandler) {
165: return null;
166: /*not called */
167: }
168:
169: public Response<BareDocumentResponse> testDocLitBareAsync(String in) {
170: return null;
171: /*not called */
172: }
173:
174: public void greetMeOneWay(String me) {
175: incrementInvocationCount("greetMeOneWay");
176: }
177:
178: public BareDocumentResponse testDocLitBare(String in) {
179: incrementInvocationCount("testDocLitBare");
180: BareDocumentResponse res = new BareDocumentResponse();
181: res.setCompany("CXF");
182: res.setId(1);
183: return res;
184: }
185:
186: private void incrementInvocationCount(String method) {
187: LOG.info("Executing " + method);
188: int n = invocationCount.get(method);
189: invocationCount.put(method, n + 1);
190: }
191:
192: public String testNillable(String nillElem, int intElem) {
193: // TODO Auto-generated method stub
194: return null;
195: }
196:
197: public Response<TestNillableResponse> testNillableAsync(
198: String nillElem, int intElem) {
199: return null;
200: }
201:
202: public Future<?> testNillableAsync(String nillElem, int intElem,
203: AsyncHandler<TestNillableResponse> asyncHandler) {
204: return null;
205: }
206:
207: }
|