public interface StreamVariable extends Serializable
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 terminal
(to avoid stalls in other operations when eg. 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.
PaintTarget.addVariable(VariableOwner, String, StreamVariable)
Modifier and Type | Interface and Description |
---|---|
static interface |
StreamVariable.StreamingEndEvent
Event passed to
#uploadFinished(StreamingEndEvent) method the
contents have been streamed to StreamVariable successfully. |
static interface |
StreamVariable.StreamingErrorEvent
Event passed to
#uploadFailed(StreamingErrorEvent) method when
the streaming ended before the end of the input. |
static interface |
StreamVariable.StreamingEvent |
static interface |
StreamVariable.StreamingProgressEvent
Event passed to
onProgress(StreamingProgressEvent) method during
the streaming progresses. |
static interface |
StreamVariable.StreamingStartEvent
Event passed to
#uploadStarted(StreamingStartEvent) method before
the streaming of the content to StreamVariable starts. |
Modifier and Type | Method and Description |
---|---|
OutputStream |
getOutputStream()
Invoked by the terminal when a new upload arrives, after
streamingStarted(StreamingStartEvent) method has been called. |
boolean |
isInterrupted()
If this method returns true while the content is being streamed the
Terminal to stop receiving current upload.
|
boolean |
listenProgress()
Whether the
#onProgress(long, long) method should be called
during the upload. |
void |
onProgress(StreamVariable.StreamingProgressEvent event)
This method is called by the terminal if
listenProgress()
returns true when the streaming starts. |
void |
streamingFailed(StreamVariable.StreamingErrorEvent event) |
void |
streamingFinished(StreamVariable.StreamingEndEvent event) |
void |
streamingStarted(StreamVariable.StreamingStartEvent event) |
OutputStream getOutputStream()
streamingStarted(StreamingStartEvent)
method has been called.
The terminal implementation will write the streamed variable to the
returned output stream.boolean listenProgress()
#onProgress(long, long)
method should be called
during the upload.
#onProgress(long, long)
is called in a synchronized block when
the content is being received. This is potentially bit slow, so we are
calling that method only if requested. The value is requested after the
#uploadStarted(StreamingStartEvent)
event, but not after reading
each buffer.
StreamVariable
wants to by notified during
the upload of the progress of streaming.onProgress(StreamingProgressEvent)
void onProgress(StreamVariable.StreamingProgressEvent event)
listenProgress()
returns true when the streaming starts.void streamingStarted(StreamVariable.StreamingStartEvent event)
void streamingFinished(StreamVariable.StreamingEndEvent event)
void streamingFailed(StreamVariable.StreamingErrorEvent event)
boolean isInterrupted()
Note, the usage of this method is not synchronized over the Application instance by the terminal like other methods. The implementation should only return a boolean field and especially not modify UI or implement a synchronization by itself.
Copyright © 2019 Vaadin Ltd. All rights reserved.