Top Description Inners Fields Constructors Methods
reactor.core.publisher

pack-priv final Class MonoUsing<T, S>

extends Mono<T>
implements Fuseable, SourceProducer<T>
Class Inheritance
All Implemented Interfaces
reactor.core.publisher.SourceProducer, org.reactivestreams.Publisher, reactor.core.Scannable, reactor.core.Fuseable
Type Parameters
<T>
the value type streamed
<S>
the resource type
Imports
java.util.Objects, java.util.concurrent.Callable, java.util.concurrent.atomic.AtomicIntegerFieldUpdater, java.util.function.Consumer, .Function, org.reactivestreams.Subscription, reactor.core.CoreSubscriber, .Exceptions, .Fuseable, reactor.util.annotation.Nullable, reactor.util.context.Context

Uses a resource, generated by a supplier for each individual Subscriber, while streaming the values from a Publisher derived from the same resource and makes sure the resource is released if the sequence terminates or the Subscriber cancels.

Eager resource cleanup happens just before the source termination and exceptions raised by the cleanup Consumer may override the terminal event. Non-eager cleanup will drop any exception.

See Also
Reactive-Streams-Commons

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final boolean
pack-priv final Consumer<? super S>
pack-priv final Callable<S>
pack-priv final Function<? super S, ? extends Mono<? extends T>>
Inherited from reactor.core.publisher.Mono:
EQUALS_BIPREDICATE

Constructor Summary

AccessConstructor and Description
pack-priv
MonoUsing(Callable<S> resourceSupplier, Function<? super S, ? extends Mono<? extends T>> sourceFactory, Consumer<? super S> resourceCleanup, boolean eager)

Method Summary

Modifier and TypeMethod and Description
public Object
scanUnsafe(Scannable.Attr<T>
a Attr to resolve for the component.
key
)

Overrides default reactor.core.publisher.SourceProducer.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place.
public void
subscribe(CoreSubscriber<? super T>
the Subscriber interested into the published sequence
actual
)

Implements abstract reactor.core.publisher.Mono.subscribe.

Implements reactor.core.CorePublisher.subscribe.

An internal Publisher#subscribe(Subscriber) that will bypass Hooks#onLastOperator(Function) pointcut.
Inherited from reactor.core.publisher.Mono:
andasblockblockblockOptionalblockOptionalcachecachecachecachecachecacheInvalidateIfcacheInvalidateWhencacheInvalidateWhencancelOncastcheckpointcheckpointcheckpointconcatWithcontextCapturecontextWritecontextWritecreatedefaultIfEmptydeferdeferContextualdelaydelaydelayElementdelayElementdelaySubscriptiondelaySubscriptiondelaySubscriptiondelayUntildematerializedoAfterTerminatedoFinallydoFirstdoOnCanceldoOnDiscarddoOnEachdoOnErrordoOnErrordoOnErrordoOnNextdoOnRequestdoOnSignaldoOnSubscribedoOnSuccessdoOnTerminalSignaldoOnTerminateelapsedelapsedemptyemptyequalsBiPredicateerrorerrorexpandexpandexpandDeepexpandDeepfilterfilterWhenfirstfirstfirstWithSignalfirstWithSignalfirstWithValuefirstWithValueflatMapflatMapIterableflatMapManyflatMapManyfluxfromfromCallablefromCompletionStagefromCompletionStagefromDirectfromFuturefromFuturefromFuturefromFuturefromRunnablefromSupplierhandlehasElementhideignoreElementignoreElementsjustjustOrEmptyjustOrEmptyloglogloglogloglogmapmapNotNullmaterializemergeWithmetricsnameneverofTypeonAssemblyonErrorCompleteonErrorCompleteonErrorCompleteonErrorContinueonErrorContinueonErrorContinueonErrorMaponErrorMaponErrorMaponErrorResumeonErrorResumeonErrorResumeonErrorReturnonErrorReturnonErrorReturnonErrorStoponTerminateDetachorpublishpublishOnrepeatrepeatrepeatrepeatrepeatWhenrepeatWhenEmptyrepeatWhenEmptyretryretryretryWhensequenceEqualsequenceEqualsequenceEqualsharesinglesingleOptionalsubscribesubscribesubscribesubscribesubscribesubscribesubscribesubscribeOnsubscribeWithswitchIfEmptytagtaketaketakeUntilOthertaptaptapthenthenthenEmptythenManythenReturntimedtimedtimeouttimeouttimeouttimeouttimeouttimeouttimestamptimestamptoFuturetoStringtransformtransformDeferredtransformDeferredContextualusingusingusingWhenusingWhenwhenwhenwhenDelayErrorwhenDelayErrorwrapzipzipzipzipzipzipzipzipzipzipzipDelayErrorzipDelayErrorzipDelayErrorzipDelayErrorzipDelayErrorzipDelayErrorzipDelayErrorzipDelayErrorzipDelayErrorzipWhenzipWhenzipWithzipWith

Field Detail

eagerback to summary
pack-priv final boolean eager
resourceCleanupback to summary
pack-priv final Consumer<? super S> resourceCleanup
resourceSupplierback to summary
pack-priv final Callable<S> resourceSupplier
sourceFactoryback to summary
pack-priv final Function<? super S, ? extends Mono<? extends T>> sourceFactory

Constructor Detail

MonoUsingback to summary
pack-priv MonoUsing(Callable<S> resourceSupplier, Function<? super S, ? extends Mono<? extends T>> sourceFactory, Consumer<? super S> resourceCleanup, boolean eager)

Method Detail

scanUnsafeback to summary
public Object scanUnsafe(Scannable.Attr<T> key)

Overrides default reactor.core.publisher.SourceProducer.scanUnsafe.

Doc from reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place. Although it is ignoring the generic type of the Attr key, implementors should take care to return values of the correct type, and return null if no specific value is available.

For public consumption of attributes, prefer using scan(Attr), which will return a typed value and fall back to the key's default if the component didn't define any mapping.

Parameters
key:Scannable.Attr<T>

a Attr to resolve for the component.

Returns:Object

the value associated to the key for that specific component, or null if none.

Annotations
@Override
subscribeback to summary
public void subscribe(CoreSubscriber<? super T> actual)

Implements abstract reactor.core.publisher.Mono.subscribe.

Implements reactor.core.CorePublisher.subscribe.

Doc from reactor.core.publisher.Mono.subscribe.

An internal Publisher#subscribe(Subscriber) that will bypass Hooks#onLastOperator(Function) pointcut.

In addition to behave as expected by Publisher#subscribe(Subscriber) in a controlled manner, it supports direct subscribe-time Context passing.

Parameters
actual:CoreSubscriber<? super T>

the Subscriber interested into the published sequence

Annotations
@Override
reactor.core.publisher back to summary

pack-priv final Class MonoUsing.MonoUsingSubscriber<T, S>

extends Object
implements InnerOperator<T, T>, Fuseable.QueueSubscription<T>
Class Inheritance
All Implemented Interfaces
reactor.core.Fuseable.QueueSubscription, org.reactivestreams.Subscription, java.util.Queue, java.util.Collection, java.lang.Iterable, reactor.core.publisher.InnerOperator, reactor.core.publisher.InnerProducer, reactor.core.Scannable, reactor.core.publisher.InnerConsumer, reactor.core.CoreSubscriber, org.reactivestreams.Subscriber

Field Summary

Modifier and TypeField and Description
pack-priv final CoreSubscriber<? super T>
pack-priv final boolean
pack-priv final boolean
pack-priv int
pack-priv Fuseable.QueueSubscription<T>
pack-priv final S
pack-priv final Consumer<? super S>
pack-priv Subscription
s

pack-priv boolean
pack-priv volatile int
pack-priv static final AtomicIntegerFieldUpdater<MonoUsing.MonoUsingSubscriber<T, S>>

Constructor Summary

AccessConstructor and Description
pack-priv
MonoUsingSubscriber(CoreSubscriber<? super T> actual, Consumer<? super S> resourceCleanup, S resource, boolean eager, boolean allowFusion)

Method Summary

Modifier and TypeMethod and Description
public CoreSubscriber<? super T>
public void
cancel()

Implements org.reactivestreams.Subscription.cancel.

Request the Publisher to stop sending data and clean up resources.
pack-priv void
public void
clear()

Implements java.util.Collection.clear.

Removes all of the elements from this collection (optional operation).
public boolean
isEmpty()

Implements java.util.Collection.isEmpty.

Returns true if this collection contains no elements.
public void
onComplete()

Implements org.reactivestreams.Subscriber.onComplete.

Successful terminal state.
public void
onError(Throwable
the throwable signaled
t
)

Implements org.reactivestreams.Subscriber.onError.

Failed terminal state.
public void
onNext(T
the element signaled
t
)

Implements org.reactivestreams.Subscriber.onNext.

Data notification sent by the Publisher in response to requests to Subscription#request(long).
public void
onSubscribe(Subscription
the Subscription that allows requesting data via Subscription#request(long)
s
)

Implements reactor.core.CoreSubscriber.onSubscribe.

Implementors should initialize any state used by onNext(Object) before calling Subscription#request(long).
public T
poll()

Implements java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.
public void
request(long
the strictly positive number of elements to requests to the upstream Publisher
n
)

Implements org.reactivestreams.Subscription.request.

No events will be sent by a Publisher until demand is signaled via this method.
public int
requestFusion(int
the mode requested by the intermediate operator
requestedMode
)

Implements reactor.core.Fuseable.QueueSubscription.requestFusion.

Request a specific fusion mode from this QueueSubscription.
public Object
scanUnsafe(Scannable.Attr<T>
a Attr to resolve for the component.
key
)

Overrides default reactor.core.publisher.InnerProducer.scanUnsafe.

Implements reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place.
public int
size()

Implements java.util.Collection.size.

Returns the number of elements in this collection.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

actualback to summary
pack-priv final CoreSubscriber<? super T> actual
allowFusionback to summary
pack-priv final boolean allowFusion
eagerback to summary
pack-priv final boolean eager
modeback to summary
pack-priv int mode
qsback to summary
pack-priv Fuseable.QueueSubscription<T> qs
Annotations
@Nullable
resourceback to summary
pack-priv final S resource
resourceCleanupback to summary
pack-priv final Consumer<? super S> resourceCleanup
sback to summary
pack-priv Subscription s
valuedback to summary
pack-priv boolean valued
wipback to summary
pack-priv volatile int wip
WIPback to summary
pack-priv static final AtomicIntegerFieldUpdater<MonoUsing.MonoUsingSubscriber<T, S>> WIP
Annotations
@SuppressWarnings:rawtypes

Constructor Detail

MonoUsingSubscriberback to summary
pack-priv MonoUsingSubscriber(CoreSubscriber<? super T> actual, Consumer<? super S> resourceCleanup, S resource, boolean eager, boolean allowFusion)

Method Detail

actualback to summary
public CoreSubscriber<? super T> actual()

Implements reactor.core.publisher.InnerProducer.actual.

Annotations
@Override
cancelback to summary
public void cancel()

Implements org.reactivestreams.Subscription.cancel.

Doc from org.reactivestreams.Subscription.cancel.

Request the Publisher to stop sending data and clean up resources.

Data may still be sent to meet previously signalled demand after calling cancel.

Annotations
@Override
cleanupback to summary
pack-priv void cleanup()
clearback to summary
public void clear()

Implements java.util.Collection.clear.

Doc from java.util.Collection.clear.

Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Implements java.util.Collection.isEmpty.

Doc from java.util.Collection.isEmpty.

Returns true if this collection contains no elements.

Returns:boolean

true if this collection contains no elements

Annotations
@Override
onCompleteback to summary
public void onComplete()

Implements org.reactivestreams.Subscriber.onComplete.

Doc from org.reactivestreams.Subscriber.onComplete.

Successful terminal state.

No further events will be sent even if Subscription#request(long) is invoked again.

Annotations
@Override
onErrorback to summary
public void onError(Throwable t)

Implements org.reactivestreams.Subscriber.onError.

Doc from org.reactivestreams.Subscriber.onError.

Failed terminal state.

No further events will be sent even if Subscription#request(long) is invoked again.

Parameters
t:Throwable

the throwable signaled

Annotations
@Override
onNextback to summary
public void onNext(T t)

Implements org.reactivestreams.Subscriber.onNext.

Doc from org.reactivestreams.Subscriber.onNext.

Data notification sent by the Publisher in response to requests to Subscription#request(long).

Parameters
t:T

the element signaled

Annotations
@Override
onSubscribeback to summary
public void onSubscribe(Subscription s)

Implements reactor.core.CoreSubscriber.onSubscribe.

Doc from reactor.core.CoreSubscriber.onSubscribe.

Implementors should initialize any state used by onNext(Object) before calling Subscription#request(long). Should further onNext related state modification occur, thread-safety will be required.

Note that an invalid request <= 0 will not produce an onError and will simply be ignored or reported through a debug-enabled reactor.util.Logger. Invoked after calling Publisher#subscribe(Subscriber).

No data will start flowing until Subscription#request(long) is invoked.

It is the responsibility of this Subscriber instance to call Subscription#request(long) whenever more data is wanted.

The Publisher will send notifications only in response to Subscription#request(long).

Parameters
s:Subscription

Doc from org.reactivestreams.Subscriber.onSubscribe.

the Subscription that allows requesting data via Subscription#request(long)

Annotations
@SuppressWarnings:unchecked
@Override
pollback to summary
public T poll()

Implements java.util.Queue.poll.

Doc from java.util.Queue.poll.

Retrieves and removes the head of this queue, or returns null if this queue is empty.

Returns:T

the head of this queue, or null if this queue is empty

Annotations
@Override
@Nullable
requestback to summary
public void request(long n)

Implements org.reactivestreams.Subscription.request.

Doc from org.reactivestreams.Subscription.request.

No events will be sent by a Publisher until demand is signaled via this method.

It can be called however often and whenever needed—but if the outstanding cumulative demand ever becomes Long.MAX_VALUE or more, it may be treated by the Publisher as "effectively unbounded".

Whatever has been requested can be sent by the Publisher so only signal demand for what can be safely handled.

A Publisher can send less than is requested if the stream ends but then must emit either Subscriber#onError(Throwable) or Subscriber#onComplete().

Parameters
n:long

the strictly positive number of elements to requests to the upstream Publisher

Annotations
@Override
requestFusionback to summary
public int requestFusion(int requestedMode)

Implements reactor.core.Fuseable.QueueSubscription.requestFusion.

Doc from reactor.core.Fuseable.QueueSubscription.requestFusion.

Request a specific fusion mode from this QueueSubscription.

One should request either SYNC, ASYNC or ANY modes (never NONE) and the implementor should return NONE, SYNC or ASYNC (never ANY).

For example, if a source supports only ASYNC fusion but the intermediate operator supports only SYNC fuseable sources, the operator may request SYNC fusion and the source can reject it via NONE, thus the operator can return NONE as well to downstream and the fusion doesn't happen.

Parameters
requestedMode:int

the mode requested by the intermediate operator

Returns:int

the actual fusion mode activated

Annotations
@Override
scanUnsafeback to summary
public Object scanUnsafe(Scannable.Attr<T> key)

Overrides default reactor.core.publisher.InnerProducer.scanUnsafe.

Implements reactor.core.Scannable.scanUnsafe.

Doc from reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place. Although it is ignoring the generic type of the Attr key, implementors should take care to return values of the correct type, and return null if no specific value is available.

For public consumption of attributes, prefer using scan(Attr), which will return a typed value and fall back to the key's default if the component didn't define any mapping.

Parameters
key:Scannable.Attr<T>

a Attr to resolve for the component.

Returns:Object

the value associated to the key for that specific component, or null if none.

Annotations
@Override
@Nullable
sizeback to summary
public int size()

Implements java.util.Collection.size.

Doc from java.util.Collection.size.

Returns the number of elements in this collection. If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this collection

Annotations
@Override