Class MultiPartByteRanges.PathContentSource

java.lang.Object
org.eclipse.jetty.http.MultiPartByteRanges.PathContentSource
All Implemented Interfaces:
Content.Source
Enclosing class:
MultiPartByteRanges

@Deprecated(forRemoval=true, since="12.0.11") public static class MultiPartByteRanges.PathContentSource extends Object implements Content.Source
Deprecated, for removal: This API element is subject to removal in a future version.

A specialized Content.Source whose Path content is sliced by a byte range.

  • Constructor Summary

    Constructors
    Constructor
    Description
    PathContentSource(Path path, ByteRange byteRange)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    demand(Runnable demandCallback)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Demands to invoke the given demand callback parameter when a chunk of content is available.
    void
    fail(Throwable failure)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Fails this content source with a last failure chunk, failing and discarding accumulated content chunks that were not yet read.
    void
    fail(Throwable failure, boolean last)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Fails this content source with a failure chunk that may or not may be last.
    long
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    Deprecated, for removal: This API element is subject to removal in a future version.
    Reads a chunk of content.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Rewinds this content, if possible, so that subsequent reads return chunks starting from the beginning of this content.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PathContentSource

      public PathContentSource(Path path, ByteRange byteRange)
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • demand

      public void demand(Runnable demandCallback)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Content.Source

      Demands to invoke the given demand callback parameter when a chunk of content is available.

      See how to use this method idiomatically.

      Implementations guarantee that calls to this method are safely reentrant so that stack overflows are avoided in the case of mutual recursion between the execution of the Runnable callback and a call to this method. Invocations of the passed Runnable are serialized and a callback for demand call is not invoked until any previous demand callback has returned. Thus the Runnable should not block waiting for a callback of a future demand call.

      The demand callback may be invoked spuriously: a subsequent call to Content.Source.read() may return null.

      Calling this method establishes a pending demand, which is fulfilled when the demand callback is invoked.

      Calling this method when there is already a pending demand results in an IllegalStateException to be thrown.

      If the invocation of the demand callback throws an exception, then Content.Source.fail(Throwable) is called.

      Specified by:
      demand in interface Content.Source
      Parameters:
      demandCallback - the demand callback to invoke where there is a content chunk available
      See Also:
    • fail

      public void fail(Throwable failure)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Content.Source

      Fails this content source with a last failure chunk, failing and discarding accumulated content chunks that were not yet read.

      The failure may be notified to the content reader at a later time, when the content reader reads a content chunk, via a Content.Chunk instance with a non null Content.Chunk.getFailure().

      If Content.Source.read() has returned a last chunk, this is a no operation.

      Typical failure: the content being aborted by user code, or idle timeouts.

      If this method has already been called, then it is a no operation.

      Specified by:
      fail in interface Content.Source
      Parameters:
      failure - the cause of the failure
      See Also:
    • fail

      public void fail(Throwable failure, boolean last)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Content.Source

      Fails this content source with a failure chunk that may or not may be last. If last is true, then the failure is persistent and a call to this method acts as Content.Source.fail(Throwable). Otherwise the failure is transient and a failure chunk will be read in order with content chunks, and subsequent calls to read may produce other content.

      A Content.Source or its reader may treat a transient failure as persistent.

      Specified by:
      fail in interface Content.Source
      Parameters:
      failure - A failure.
      last - true if the failure is persistent, false if the failure is transient.
      See Also:
    • getLength

      public long getLength()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      getLength in interface Content.Source
      Returns:
      the content length, if known, or -1 if the content length is unknown
    • read

      public Content.Chunk read()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Content.Source

      Reads a chunk of content.

      See how to use this method idiomatically.

      The returned chunk could be:

      • null, to signal that there isn't a chunk of content available
      • an Content.Chunk instance with non null Content.Chunk.getFailure(), to signal that there was a failure trying to produce a chunk of content, or that the content production has been failed externally
      • a Content.Chunk instance, containing the chunk of content.

      Once a read returns an Content.Chunk instance with non-null Content.Chunk.getFailure() then if the failure is last further reads will continue to return the same failure chunk instance, otherwise further read() operations may return different non-failure chunks.

      Once a read returns a last chunk, further reads will continue to return a last chunk (although the instance may be different).

      The content reader code must ultimately arrange for a call to Retainable.release() on the returned Content.Chunk.

      Additionally, prior to the ultimate call to Retainable.release(), the reader code may make additional calls to Retainable.retain(), that must ultimately be matched by a correspondent number of calls to Retainable.release().

      Concurrent reads from different threads are not recommended, as they are inherently in a race condition.

      Reads performed outside the invocation context of a demand callback are allowed. However, reads performed with a pending demand are inherently in a race condition (the thread that reads with the thread that invokes the demand callback).

      Specified by:
      read in interface Content.Source
      Returns:
      a chunk of content, possibly a failure instance, or null
      See Also:
    • rewind

      public boolean rewind()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Content.Source

      Rewinds this content, if possible, so that subsequent reads return chunks starting from the beginning of this content.

      Specified by:
      rewind in interface Content.Source
      Returns:
      true if this content has been rewound, false if this content cannot be rewound