Interface InputStreamFactory
- All Superinterfaces:
Serializable
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
StreamResource.
The instance of this class should generate InputStream for the
resource.
- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionProduceInputStreaminstance to read resource data.default booleanIf this method returnstrue(by default) then reading data from input stream (viacreateInputStream()will be done under session lock and it's safe to access application data withinInputStreamread methods.
-
Method Details
-
createInputStream
InputStream createInputStream()ProduceInputStreaminstance 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
InputStreamdata. The presence of the lock on subsequent access to theInputStreamis controlled byrequiresLock()method. SocreateInputStream()method is the best place to do yourInputStreaminitialization.Return value may not be null.
- Returns:
- data input stream. May not be null.
-
requiresLock
default boolean requiresLock()If this method returnstrue(by default) then reading data from input stream (viacreateInputStream()will be done under session lock and it's safe to access application data withinInputStreamread 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. ifInputStreaminstance is remote URL input stream then you don't want to lock session on reading data from it.- Returns:
trueif data from the input stream should be read under the session lock,falseotherwise
-