本文整理匯總了Java中com.google.common.util.concurrent.FutureCallback.onSuccess方法的典型用法代碼示例。如果您正苦於以下問題:Java FutureCallback.onSuccess方法的具體用法?Java FutureCallback.onSuccess怎麽用?Java FutureCallback.onSuccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.util.concurrent.FutureCallback
的用法示例。
在下文中一共展示了FutureCallback.onSuccess方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doProcess
import com.google.common.util.concurrent.FutureCallback; //導入方法依賴的package包/類
@Override
protected FResult<JSONObject> doProcess(UploadRequest request, FutureCallback<Object> response) {
try {
System.out.println(name);
if (response!=null) {
response.onSuccess(name+"response ok");
}
JSONObject o = new JSONObject();
o.put("name", name);
return FResult.newSuccess(o);
} catch (Exception e) {
return FResult.newFailure(1, e.getMessage());
}
}
示例2: abort
import com.google.common.util.concurrent.FutureCallback; //導入方法依賴的package包/類
@Override
public void abort(final FutureCallback<Void> abortCallback) {
if (!dataTree.startAbort(this)) {
abortCallback.onSuccess(null);
return;
}
candidate = null;
state = State.ABORTED;
final Optional<List<Future<Object>>> maybeAborts = userCohorts.abort();
if (!maybeAborts.isPresent()) {
abortCallback.onSuccess(null);
return;
}
final Future<Iterable<Object>> aborts = Futures.sequence(maybeAborts.get(), ExecutionContexts.global());
if (aborts.isCompleted()) {
abortCallback.onSuccess(null);
return;
}
aborts.onComplete(new OnComplete<Iterable<Object>>() {
@Override
public void onComplete(final Throwable failure, final Iterable<Object> objs) {
if (failure != null) {
abortCallback.onFailure(failure);
} else {
abortCallback.onSuccess(null);
}
}
}, ExecutionContexts.global());
}