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.cxf.greeter_control;
019:
020: import java.util.concurrent.Future;
021: import java.util.logging.Logger;
022:
023: import javax.xml.ws.AsyncHandler;
024: import javax.xml.ws.Response;
025:
026: import org.apache.cxf.greeter_control.types.FaultDetail;
027: import org.apache.cxf.greeter_control.types.GreetMeResponse;
028: import org.apache.cxf.greeter_control.types.PingMeResponse;
029: import org.apache.cxf.greeter_control.types.SayHiResponse;
030:
031: /**
032: *
033: */
034:
035: public class AbstractGreeterImpl implements Greeter {
036:
037: private static final Logger LOG = Logger
038: .getLogger(AbstractGreeterImpl.class.getName());
039: private long delay;
040: private String lastOnewayArg;
041: private boolean throwAlways;
042: private boolean useLastOnewayArg;
043: private int pingMeCount;
044:
045: public long getDelay() {
046: return delay;
047: }
048:
049: public void setDelay(long d) {
050: delay = d;
051: }
052:
053: public void resetLastOnewayArg() {
054: lastOnewayArg = null;
055: }
056:
057: public void useLastOnewayArg(Boolean use) {
058: useLastOnewayArg = use;
059: }
060:
061: public void setThrowAlways(boolean t) {
062: throwAlways = t;
063: }
064:
065: public String greetMe(String arg0) {
066: LOG.fine("Executing operation greetMe with parameter: " + arg0);
067: if (delay > 0) {
068: try {
069: Thread.sleep(delay);
070: } catch (InterruptedException ex) {
071: // ignore
072: }
073: }
074: String result = null;
075: synchronized (this ) {
076: result = useLastOnewayArg ? lastOnewayArg : arg0
077: .toUpperCase();
078: }
079: LOG.fine("returning: " + result);
080: return result;
081: }
082:
083: public Future<?> greetMeAsync(String arg0,
084: AsyncHandler<GreetMeResponse> arg1) {
085: // TODO Auto-generated method stub
086: return null;
087: }
088:
089: public Response<GreetMeResponse> greetMeAsync(String arg0) {
090: // TODO Auto-generated method stub
091: return null;
092: }
093:
094: public void greetMeOneWay(String arg0) {
095: synchronized (this ) {
096: lastOnewayArg = arg0;
097: }
098: LOG.fine("Executing operation greetMeOneWay with parameter: "
099: + arg0);
100: }
101:
102: public void pingMe() throws PingMeFault {
103: pingMeCount++;
104: if ((pingMeCount % 2) == 0 || throwAlways) {
105: LOG
106: .fine("Throwing PingMeFault while executiong operation pingMe");
107: FaultDetail fd = new FaultDetail();
108: fd.setMajor((short) 2);
109: fd.setMinor((short) 1);
110: throw new PingMeFault(
111: "Pings succeed only every other time.", fd);
112: } else {
113: LOG.fine("Executing operation pingMe");
114: }
115: }
116:
117: public Response<PingMeResponse> pingMeAsync() {
118: // TODO Auto-generated method stub
119: return null;
120: }
121:
122: public Future<?> pingMeAsync(AsyncHandler<PingMeResponse> arg0) {
123: // TODO Auto-generated method stub
124: return null;
125: }
126:
127: public String sayHi() {
128: // TODO Auto-generated method stub
129: return null;
130: }
131:
132: public Response<SayHiResponse> sayHiAsync() {
133: // TODO Auto-generated method stub
134: return null;
135: }
136:
137: public Future<?> sayHiAsync(AsyncHandler<SayHiResponse> arg0) {
138: // TODO Auto-generated method stub
139: return null;
140: }
141:
142: }
|