1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
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 package org.apache.thrift.async;
20 
21 /**
22  * A handler interface asynchronous clients can implement to receive future notice of the results of
23  * an asynchronous method call.
24  *
25  * @param <T> The return type of the asynchronously invoked method.
26  */
27 public interface AsyncMethodCallback<T> {
28   /**
29    * This method will be called when the remote side has completed invoking your method call and the
30    * result is fully read. For {@code oneway} method calls, this method will be called as soon as we
31    * have completed writing out the request.
32    *
33    * @param response The return value of the asynchronously invoked method; {@code null} for void
34    *     methods which includes {@code oneway} methods.
35    */
onComplete(T response)36   void onComplete(T response);
37 
38   /**
39    * This method will be called when there is either an unexpected client-side exception like an
40    * IOException or else when the remote method raises an exception, either declared in the IDL or
41    * due to an unexpected server-side error.
42    *
43    * @param exception The exception encountered processing the the asynchronous method call, may be
44    *     a local exception or an unmarshalled remote exception.
45    */
onError(Exception exception)46   void onError(Exception exception);
47 }
48