- java.lang.Object
-
- io.smallrye.mutiny.subscription.UniSerializedSubscriber<T>
-
- All Implemented Interfaces:
Cancellable,ContextSupport,UniSubscriber<T>,UniSubscription,java.util.concurrent.Flow.Subscription
public class UniSerializedSubscriber<T> extends java.lang.Object implements UniSubscriber<T>, UniSubscription
An implementation ofUniSubscriberandUniSubscriptionmaking sure event handlers are only called once.
-
-
Constructor Summary
Constructors Constructor Description UniSerializedSubscriber(AbstractUni<T> upstream, UniSubscriber<? super T> subscriber)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Requests theUnito cancel and clean up resources.Contextcontext()Provide a context.voidonFailure(java.lang.Throwable throwable)Called if the computation of the item by the subscriberUnifailed.voidonItem(T item)Event handler called once the item has been computed by the subscribedUni.voidonSubscribe(UniSubscription subscription)Event handler called once the subscribedUnihas taken into account the subscription.static <T> voidsubscribe(AbstractUni<T> source, UniSubscriber<? super T> subscriber)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.smallrye.mutiny.subscription.UniSubscription
request
-
-
-
-
Constructor Detail
-
UniSerializedSubscriber
public UniSerializedSubscriber(AbstractUni<T> upstream, UniSubscriber<? super T> subscriber)
-
-
Method Detail
-
subscribe
public static <T> void subscribe(AbstractUni<T> source, UniSubscriber<? super T> subscriber)
-
context
public Context context()
Description copied from interface:ContextSupportProvide a context.Since calls to this method shall only be triggered when a Mutiny pipeline uses a
withContextoperator, there is no need in general for caching the context value in a field of the implementing class. Exceptions include operators that have cross-subscriber semantics such as memoizers or broadcasters.This method is expected to be called once per
withContextoperator.- Specified by:
contextin interfaceContextSupport- Returns:
- the context, must not be
null.
-
onSubscribe
public void onSubscribe(UniSubscription subscription)
Description copied from interface:UniSubscriberEvent handler called once the subscribedUnihas taken into account the subscription. TheUnihave triggered the computation of the item.IMPORTANT:
UniSubscriber.onItem(Object)andUniSubscriber.onFailure(Throwable)would not be called before the invocation of this method.- Executor: Operate on no particular executor, except if
Uni.runSubscriptionOn(Executor)has been called - Exception: Throwing an exception cancels the subscription,
UniSubscriber.onItem(Object)andUniSubscriber.onFailure(Throwable)won't be called
- Specified by:
onSubscribein interfaceUniSubscriber<T>- Parameters:
subscription- the subscription allowing to cancel the computation.
- Executor: Operate on no particular executor, except if
-
onItem
public void onItem(T item)
Description copied from interface:UniSubscriberEvent handler called once the item has been computed by the subscribedUni.IMPORTANT: this method will be only called once per subscription. If
UniSubscriber.onFailure(Throwable)is called, this method won't be called.- Executor: Operate on no particular executor, except if
Uni.emitOn(java.util.concurrent.Executor)has been called - Exception: Throwing an exception cancels the subscription.
- Specified by:
onItemin interfaceUniSubscriber<T>- Parameters:
item- the item, may benull.
- Executor: Operate on no particular executor, except if
-
onFailure
public void onFailure(java.lang.Throwable throwable)
Description copied from interface:UniSubscriberCalled if the computation of the item by the subscriberUnifailed.IMPORTANT: this method will be only called once per subscription. If
UniSubscriber.onItem(Object)is called, this method won't be called.- Executor: Operate on no particular executor, except if
Uni.emitOn(java.util.concurrent.Executor)has been called - Exception: Throwing an exception cancels the subscription.
- Specified by:
onFailurein interfaceUniSubscriber<T>- Parameters:
throwable- the failure, cannot benull.
- Executor: Operate on no particular executor, except if
-
cancel
public void cancel()
Description copied from interface:UniSubscriptionRequests theUnito cancel and clean up resources. If the item is retrieved after cancellation, it is not forwarded to the subscriber. If the cancellation happens after the delivery of the item, this call is ignored.Calling this method, emits the
cancellationevent upstream.- Specified by:
cancelin interfaceCancellable- Specified by:
cancelin interfacejava.util.concurrent.Flow.Subscription- Specified by:
cancelin interfaceUniSubscription
-
-