Class ActiveTransfer

java.lang.Object
com.vaadin.flow.internal.streams.ActiveTransfer
All Implemented Interfaces:
Serializable

public class ActiveTransfer extends Object implements Serializable
An upload or download request that is currently being served for a UI.

The UI that an active transfer belongs to is kept attached to its session even if the UI is closed, so that listeners and callbacks bound to that UI are still effective while the transfer is ongoing. A transfer is terminated when the session is invalidated, which makes the streams that the framework has handed out to the request handler refuse to transfer any more bytes.

For internal use only. May be renamed or removed in a future release.

See Also:
  • Constructor Details

    • ActiveTransfer

      public ActiveTransfer(String path, Element owner)
      Creates a record for a transfer that is served from the given path for the given owner element.
      Parameters:
      path - the path of the request being served, used for logging
      owner - the element that owns the request handler, used for logging, not null
  • Method Details

    • terminate

      public void terminate()
      Terminates this transfer, which makes the streams handed out for it stop transferring bytes.
    • isTerminated

      public boolean isTerminated()
      Checks whether this transfer has been terminated.
      Returns:
      true if the transfer has been terminated, false otherwise
    • wrapRequest

      public VaadinRequest wrapRequest(VaadinRequest request)
      Returns the given request with any stream that it hands out replaced by one that stops transferring bytes once this transfer is terminated.

      A request implementation that the framework doesn't know how to wrap is returned as-is.

      Parameters:
      request - the request to wrap, not null
      Returns:
      the wrapped request
    • wrapResponse

      public VaadinResponse wrapResponse(VaadinResponse response)
      Returns the given response with any stream that it hands out replaced by one that stops transferring bytes once this transfer is terminated.

      A response implementation that the framework doesn't know how to wrap is returned as-is.

      Parameters:
      response - the response to wrap, not null
      Returns:
      the wrapped response
    • getDescription

      public String getDescription()
      Describes this transfer for logging purposes.
      Returns:
      a description of this transfer