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