Package com.linecorp.armeria.server.file
Class AbstractBlockingHttpVfs
java.lang.Object
com.linecorp.armeria.server.file.AbstractHttpVfs
com.linecorp.armeria.server.file.AbstractBlockingHttpVfs
- All Implemented Interfaces:
HttpVfs
A skeletal
HttpVfs
implementation for accessing file system with blocking I/O.
All its operations are executed in the given fileReadExecutor
via the blocking I/O methods,
such as blockingGet(Executor, String, Clock, String, HttpHeaders, MediaTypeResolver)
.-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractBlockingHttpVfs
(boolean directoryListingSupported) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
blockingCanList
(Executor fileReadExecutor, String path) Returns whether the file at the specifiedpath
is a listable directory.protected abstract HttpFile
blockingGet
(Executor fileReadExecutor, String path, Clock clock, @Nullable String contentEncoding, HttpHeaders additionalHeaders, MediaTypeResolver mediaTypeResolver) Finds the file at the specifiedpath
.blockingList
(Executor fileReadExecutor, String path) Lists the files at the specified directorypath
non-recursively.final CompletableFuture<Boolean>
Returns whether the file at the specifiedpath
is a listable directory.final HttpFile
get
(Executor fileReadExecutor, String path, Clock clock, @Nullable String contentEncoding, HttpHeaders additionalHeaders) Deprecated.final HttpFile
get
(Executor fileReadExecutor, String path, Clock clock, @Nullable String contentEncoding, HttpHeaders additionalHeaders, MediaTypeResolver mediaTypeResolver) Finds the file at the specifiedpath
.final CompletableFuture<List<String>>
Lists the files at the specified directorypath
non-recursively.Methods inherited from class com.linecorp.armeria.server.file.AbstractHttpVfs
toString
-
Constructor Details
-
AbstractBlockingHttpVfs
protected AbstractBlockingHttpVfs(boolean directoryListingSupported) Creates a new instance.- Parameters:
directoryListingSupported
- whether thisHttpVfs
supports directory listing. Iffalse
,blockingCanList(Executor, String)
andblockingList(Executor, String)
will never be invoked.
-
-
Method Details
-
get
@Deprecated public final HttpFile get(Executor fileReadExecutor, String path, Clock clock, @Nullable @Nullable String contentEncoding, HttpHeaders additionalHeaders) Deprecated.Finds the file at the specifiedpath
. This method invokesblockingGet(Executor, String, Clock, String, HttpHeaders, MediaTypeResolver)
from the specifiedfileReadExecutor
.- Parameters:
fileReadExecutor
- theExecutor
which will perform the read operations against the filepath
- an absolute path that starts with'/'
, whose component separator is'/'
clock
- theClock
which provides the current date and timecontentEncoding
- the desired'content-encoding'
header value of the file.null
to omit the header.additionalHeaders
- the additional HTTP headers to add to the returnedHttpFile
.- Returns:
- the
HttpFile
at the specifiedpath
-
get
public final HttpFile get(Executor fileReadExecutor, String path, Clock clock, @Nullable @Nullable String contentEncoding, HttpHeaders additionalHeaders, MediaTypeResolver mediaTypeResolver) Finds the file at the specifiedpath
. This method invokesblockingGet(Executor, String, Clock, String, HttpHeaders, MediaTypeResolver)
from the specifiedfileReadExecutor
.- Parameters:
fileReadExecutor
- theExecutor
which will perform the read operations against the filepath
- an absolute path that starts with'/'
, whose component separator is'/'
clock
- theClock
which provides the current date and timecontentEncoding
- the desired'content-encoding'
header value of the file.null
to omit the header.additionalHeaders
- the additional HTTP headers to add to the returnedHttpFile
.mediaTypeResolver
- theMediaTypeResolver
to determine theMediaType
.- Returns:
- the
HttpFile
at the specifiedpath
-
blockingGet
protected abstract HttpFile blockingGet(Executor fileReadExecutor, String path, Clock clock, @Nullable @Nullable String contentEncoding, HttpHeaders additionalHeaders, MediaTypeResolver mediaTypeResolver) Finds the file at the specifiedpath
.- Parameters:
fileReadExecutor
- theExecutor
which will perform the read operations against the filepath
- an absolute path that starts with'/'
, whose component separator is'/'
clock
- theClock
which provides the current date and timecontentEncoding
- the desired'content-encoding'
header value of the file.null
to omit the header.additionalHeaders
- the additional HTTP headers to add to the returnedHttpFile
.mediaTypeResolver
- theMediaTypeResolver
to determine theMediaType
.- Returns:
- the
HttpFile
at the specifiedpath
-
canList
Returns whether the file at the specifiedpath
is a listable directory. This method invokesblockingCanList(Executor, String)
from the specifiedfileReadExecutor
.- Specified by:
canList
in interfaceHttpVfs
- Overrides:
canList
in classAbstractHttpVfs
- Parameters:
fileReadExecutor
- theExecutor
which will perform the read operations against the filepath
- an absolute path that starts with'/'
, whose component separator is'/'
- Returns:
- the
CompletableFuture
that will be completed withtrue
if the file is a listable directory. It will be completed withfalse
if the directory does not exist or the file listing is not available.
-
blockingCanList
Returns whether the file at the specifiedpath
is a listable directory. This method returnsfalse
by default.- Parameters:
fileReadExecutor
- theExecutor
which will perform the read operations against the filepath
- an absolute path that starts with'/'
, whose component separator is'/'
- Returns:
true
if the file is a listable directory.false
if the directory does not exist or the file listing is not available.
-
list
Lists the files at the specified directorypath
non-recursively. This method invokesblockingList(Executor, String)
from the specifiedfileReadExecutor
.- Specified by:
list
in interfaceHttpVfs
- Overrides:
list
in classAbstractHttpVfs
- Parameters:
fileReadExecutor
- theExecutor
which will perform the read operations against the filepath
- an absolute path that starts with'/'
, whose component separator is'/'
- Returns:
- the
CompletableFuture
that will be completed with the list of the file names. If the file is a directory, the file name will end with'/'
. If the directory does not exist or the file listing is not available, it will be completed with an emptyList
.
-
blockingList
Lists the files at the specified directorypath
non-recursively. This method returns an empty list by default.- Parameters:
fileReadExecutor
- theExecutor
which will perform the read operations against the filepath
- an absolute path that starts with'/'
, whose component separator is'/'
- Returns:
- the list of the file names. If the file is a directory, the file name will end with
'/'
. If the directory does not exist or the file listing is not available, an emptyList
is returned.
-
get(Executor, String, Clock, String, HttpHeaders, MediaTypeResolver)
instead.