com.vaadin.flow.server.
Interface InputStreamFactory
All Superinterfaces:
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Creates input stream instances that provides the actual data of a
StreamResource
.
The instance of this class should generate InputStream
for the
resource.
Since:
1.0
Author:
Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionProduce
InputStream
instance to read resource data.default boolean
If this method returns
true
(by default) then reading data from input stream (viacreateInputStream()
will be done under session lock and it's safe to access application data withinInputStream
read methods.
-
Method Details
-
createInputStream
InputStream createInputStream()Produce
InputStream
instance to read resource data.This method is called under the Vaadin session lock. So it's safe to access the application/session data which is required to produce the
InputStream
data. The presence of the lock on subsequent access to theInputStream
is controlled byrequiresLock()
method. SocreateInputStream()
method is the best place to do yourInputStream
initialization.Return value may not be null.
Returns:
data input stream. May not be null.
-
requiresLock
default boolean requiresLock()If this method returns
true
(by default) then reading data from input stream (viacreateInputStream()
will be done under session lock and it's safe to access application data withinInputStream
read methods. Otherwise session lock won't be acquired. In the latter case one must not try to access application data.createInputStream()
is called under the session lock. Normally it should be enough to get all required data from the application at this point and use it to produce the data viaInputStream
. In this case one should overriderequiresLock()
method to returnfalse
. E.g. ifInputStream
instance is remote URL input stream then you don't want to lock session on reading data from it.Returns:
true
if data from the input stream should be read under the session lock,false
otherwise
-