01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.axis2.client.async;
21:
22: /**
23: * Base class for asynchronous client callback handler. The application code
24: * needs to create an instance of this class (actually an instance of a
25: * subclass, since this base class cannot be used directly) and pass it to the
26: * generated startXXX client stub method when initiating an asynchronous
27: * operation. The Axis2 code then calls the appropriate methods of this class
28: * {@link #setComplete(boolean)}, and either {@link #onComplete(AsyncResult)}
29: * or {@link #onError(Exception)} when the operation is completed.
30: *
31: * @deprecated Please use AxisCallback instead, this class is deprecated as of 1.3
32: */
33: public abstract class Callback {
34:
35: /**
36: * Field complete
37: */
38: private boolean complete;
39:
40: /**
41: * Method is invoked by Axis2 once the asynchronous operation has completed
42: * successfully.
43: *
44: * @param result
45: */
46: public abstract void onComplete(AsyncResult result);
47:
48: /**
49: * Method invoked by Axis2 if the asynchronous operation fails.
50: *
51: * @param e
52: */
53: public abstract void onError(Exception e);
54:
55: /**
56: * Returns true if the asynchronous operation has completed, false otherwise. Typically this is
57: * used for polling. e.g.
58: * <code>
59: * <pre>
60: * while(!callback.isComplete()){
61: * Thread.sleep(1000);
62: * }
63: * do whatever u need to do
64: * </pre>
65: * </code>
66: *
67: * @return boolean
68: */
69: public synchronized boolean isComplete() {
70: return complete;
71: }
72:
73: /**
74: * Method invoked by Axis2 to set the completion state of the operation.
75: *
76: * @param complete
77: */
78: public final synchronized void setComplete(boolean complete) {
79: this.complete = complete;
80: notify();
81: }
82: }
|