接口的使用
cn.dinodev.spring.commons.promise.Promise
使用Promise的程序包
-
cn.dinodev.spring.commons.promise中Promise的使用
修饰符和类型接口说明interfaceDeferred<D>Deferred interface to trigger an event (resolve, reject, notify).修饰符和类型方法说明AbstractPromise.always(AlwaysCallback<? super D> callback) Promise.always(AlwaysCallback<? super D> callback) This method will registerAlwaysCallbackso that when a Deferred object is either resolved (Deferred.resolve(Object)) or rejected (Deferred#reject(Object)),AlwaysCallbackwill be triggered.This method will registerDoneCallbackso that when a Deferred object is resolved (Deferred.resolve(Object)),DoneCallbackwill be triggered.This method will registerFailCallbackso that when a Deferred object is rejected (Deferred#reject(Object)),FailCallbackwill be triggered.Deferred.promise()Return anPromiseinstance (i.e., an observer).DeferredObject.promise()Equivalent todone(DoneCallback)Equivalent todone(DoneCallback).fail(FailCallback) -
cn.dinodev.spring.commons.utils中Promise的使用
修饰符和类型方法说明static <R> Promise<R>TaskUtils.exec(Callable<R> task, Predicate<R> checker, int attempts, Class<? extends RuntimeException>... throwOutExceptions) 无参数,有返回的任务调用static <R> Promise<R>TaskUtils.exec(Callable<R> task, Predicate<R> checker, int attempts, Duration nap, Class<? extends RuntimeException>... throwOutExceptions) 无参数,有返回的任务调用<T,U, R> Promise<R> TaskUtils.exec(BiFunction<T, U, R> task, T paramFirst, U paramSecond, Predicate<R> checker, int attempts, Class<? extends RuntimeException>... throwOutExceptions) task接受两个参数,并返回执行结果<T,U, R> Promise<R> TaskUtils.exec(BiFunction<T, U, R> task, T paramFirst, U paramSecond, Predicate<R> checker, int attempts, Duration nap, Class<? extends RuntimeException>... throwOutExceptions) task接受两个参数,并返回执行结果<T,R> Promise<R> TaskUtils.exec(Function<T, R> task, T param, Predicate<R> checker, int attempts, Class<? extends RuntimeException>... throwOutExceptions) task接受一个参数,并返回执行结果<T,R> Promise<R> TaskUtils.exec(Function<T, R> task, T param, Predicate<R> checker, int attempts, Duration nap, Class<? extends RuntimeException>... throwOutExceptions) task接受一个参数,并返回执行结果