Interface StreamVariable

  • All Superinterfaces:
    Serializable

    public interface StreamVariable
    extends Serializable
    StreamVariable is a special kind of variable whose value is streamed to an OutputStream provided by the getOutputStream() method. E.g. in web terminals StreamVariable can be used to send large files from browsers to the server without consuming large amounts of memory.

    Note, writing to the OutputStream is not synchronized by the handler (to avoid stalls in other operations when e.g. streaming to a slow network service or file system). If UI is changed as a side effect of writing to the output stream, developer must handle synchronization manually.

    Since:
    1.0.
    Author:
    Vaadin Ltd
    • Method Detail

      • getOutputStream

        OutputStream getOutputStream()
        Invoked when a new upload arrives, after streamingStarted(StreamingStartEvent) method has been called. The implementation will write the streamed variable to the returned output stream.
        Returns:
        Stream to which the uploaded file should be written.
      • streamingStarted

        void streamingStarted​(StreamVariable.StreamingStartEvent event)
        This method is called when the streaming starts.
        Parameters:
        event - streaming start event
      • streamingFinished

        void streamingFinished​(StreamVariable.StreamingEndEvent event)
        This method is called when the streaming has finished.
        Parameters:
        event - streaming end event
      • streamingFailed

        void streamingFailed​(StreamVariable.StreamingErrorEvent event)
        This method is called when the streaming has failed.
        Parameters:
        event - streaming error event
      • isInterrupted

        boolean isInterrupted()
        If this method returns true while the content is being streamed the handler is told to stop receiving the current upload.

        Note, the usage of this method is not synchronized over the Application instance like other methods. The implementation should only return a boolean field and especially not modify UI or implement a synchronization by itself.

        Returns:
        true if the streaming should be interrupted as soon as possible.