Top Description Inners Fields Constructors Methods
org.springframework.http.server.reactive

pack-priv Class WriteResultPublisher

extends Object
implements Publisher<Void>
Class Inheritance
All Implemented Interfaces
org.reactivestreams.Publisher
Imports
java.util.concurrent.atomic.AtomicReference, org.apache.commons.logging.Log, org.reactivestreams.Publisher, .Subscriber, .Subscription, reactor.core.publisher.Operators, org.springframework.core.log.LogDelegateFactory, org.springframework.lang.Nullable, org.springframework.util.Assert

Publisher returned from ServerHttpResponse#writeWith(Publisher).
Authors
Arjen Poutsma, Violeta Georgieva, Rossen Stoyanchev
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
WriteResultPublisher.State

Represents a state for the Publisher to be in.

    UNSUBSCRIBED
         |
         v
    SUBSCRIBING
         |
         v
     SUBSCRIBED
         |
         v
     COMPLETED
private static class
WriteResultPublisher.WriteResultSubscription

Subscription to receive and delegate request and cancel signals from the subscriber to this publisher.

Field Summary

Modifier and TypeField and Description
private final Runnable
private volatile boolean
private volatile Throwable
private final String
private static final Log
rsWriteResultLogger

Special logger for debugging Reactive Streams signals.

private final AtomicReference<WriteResultPublisher.State>
private volatile Subscriber<? super Void>

Constructor Summary

AccessConstructor and Description
public
WriteResultPublisher(String logPrefix, Runnable cancelTask)

Method Summary

Modifier and TypeMethod and Description
private boolean
public void
publishComplete()

Invoke this to delegate a completion signal to the subscriber.

public void
publishError(Throwable t)

Invoke this to delegate an error signal to the subscriber.

public final void
subscribe(Subscriber<? super Void>
the Subscriber that will consume signals from this Publisher
subscriber
)

Implements org.reactivestreams.Publisher.subscribe.

Request Publisher to start streaming data.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cancelTaskback to summary
private final Runnable cancelTask
completedBeforeSubscribedback to summary
private volatile boolean completedBeforeSubscribed
errorBeforeSubscribedback to summary
private volatile Throwable errorBeforeSubscribed
Annotations
@Nullable
logPrefixback to summary
private final String logPrefix
rsWriteResultLoggerback to summary
private static final Log rsWriteResultLogger

Special logger for debugging Reactive Streams signals.

See Also
LogDelegateFactory#getHiddenLog(Class), AbstractListenerReadPublisher#rsReadLogger, AbstractListenerWriteProcessor#rsWriteLogger, AbstractListenerWriteFlushProcessor#rsWriteFlushLogger
stateback to summary
private final AtomicReference<WriteResultPublisher.State> state
subscriberback to summary
private volatile Subscriber<? super Void> subscriber
Annotations
@Nullable

Constructor Detail

WriteResultPublisherback to summary
public WriteResultPublisher(String logPrefix, Runnable cancelTask)

Method Detail

changeStateback to summary
private boolean changeState(WriteResultPublisher.State oldState, WriteResultPublisher.State newState)
publishCompleteback to summary
public void publishComplete()

Invoke this to delegate a completion signal to the subscriber.

publishErrorback to summary
public void publishError(Throwable t)

Invoke this to delegate an error signal to the subscriber.

subscribeback to summary
public final void subscribe(Subscriber<? super Void> subscriber)

Implements org.reactivestreams.Publisher.subscribe.

Doc from org.reactivestreams.Publisher.subscribe.

Request Publisher to start streaming data.

This is a "factory method" and can be called multiple times, each time starting a new Subscription.

Each Subscription will work for only a single Subscriber.

A Subscriber should only subscribe once to a single Publisher.

If the Publisher rejects the subscription attempt or otherwise fails it will signal the error via Subscriber#onError(Throwable).

Parameters
subscriber:Subscriber<? super Void>

the Subscriber that will consume signals from this Publisher

Annotations
@Override
org.springframework.http.server.reactive back to summary

private sealed Enum WriteResultPublisher.State

extends Enum<WriteResultPublisher.State>
Class Inheritance

Represents a state for the Publisher to be in.

    UNSUBSCRIBED
         |
         v
    SUBSCRIBING
         |
         v
     SUBSCRIBED
         |
         v
     COMPLETED

Field Summary

Modifier and TypeField and Description
public static final WriteResultPublisher.State
public static final WriteResultPublisher.State
public static final WriteResultPublisher.State
public static final WriteResultPublisher.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv void
pack-priv void
pack-priv void
request(WriteResultPublisher publisher, long n)

pack-priv void
subscribe(WriteResultPublisher publisher, Subscriber<? super Void> subscriber)

public static WriteResultPublisher.State
public static WriteResultPublisher.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

COMPLETEDback to summary
public static final WriteResultPublisher.State COMPLETED
SUBSCRIBEDback to summary
public static final WriteResultPublisher.State SUBSCRIBED
SUBSCRIBINGback to summary
public static final WriteResultPublisher.State SUBSCRIBING
UNSUBSCRIBEDback to summary
public static final WriteResultPublisher.State UNSUBSCRIBED

Constructor Detail

Stateback to summary
private State()

Method Detail

cancelback to summary
pack-priv void cancel(WriteResultPublisher publisher)
publishCompleteback to summary
pack-priv void publishComplete(WriteResultPublisher publisher)
publishErrorback to summary
pack-priv void publishError(WriteResultPublisher publisher, Throwable t)
requestback to summary
pack-priv void request(WriteResultPublisher publisher, long n)
subscribeback to summary
pack-priv void subscribe(WriteResultPublisher publisher, Subscriber<? super Void> subscriber)
valueOfback to summary
public static WriteResultPublisher.State valueOf(String name)
valuesback to summary
public static WriteResultPublisher.State[] values()
org.springframework.http.server.reactive back to summary

private final Class WriteResultPublisher.WriteResultSubscription

extends Object
implements Subscription
Class Inheritance
  • java.lang.Object
  • org.springframework.http.server.reactive.WriteResultPublisher.WriteResultSubscription
All Implemented Interfaces
org.reactivestreams.Subscription

Subscription to receive and delegate request and cancel signals from the subscriber to this publisher.

Field Summary

Modifier and TypeField and Description
private final WriteResultPublisher

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public final void
cancel()

Implements org.reactivestreams.Subscription.cancel.

Request the Publisher to stop sending data and clean up resources.
private WriteResultPublisher.State
public final 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.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

publisherback to summary
private final WriteResultPublisher publisher

Constructor Detail

WriteResultSubscriptionback to summary
public WriteResultSubscription(WriteResultPublisher publisher)

Method Detail

cancelback to summary
public final 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
getStateback to summary
private WriteResultPublisher.State getState()
requestback to summary
public final 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