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
public abstract class AbstractBlockingHttpVfs extends AbstractHttpVfs
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)
.-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractBlockingHttpVfs(boolean directoryListingSupported)
Creates a new instance. -
Method Summary
Modifier and Type Method Description protected 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, String contentEncoding, HttpHeaders additionalHeaders)
Finds the file at the specifiedpath
.protected List<String>
blockingList(Executor fileReadExecutor, String path)
Lists the files at the specified directorypath
non-recursively.CompletableFuture<Boolean>
canList(Executor fileReadExecutor, String path)
Returns whether the file at the specifiedpath
is a listable directory.HttpFile
get(Executor fileReadExecutor, String path, Clock clock, String contentEncoding, HttpHeaders additionalHeaders)
Finds the file at the specifiedpath
.CompletableFuture<List<String>>
list(Executor fileReadExecutor, String path)
Lists the files at the specified directorypath
non-recursively.
-
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
public final HttpFile get(Executor fileReadExecutor, String path, Clock clock, @Nullable String contentEncoding, HttpHeaders additionalHeaders)Finds the file at the specifiedpath
. This method invokesblockingGet(Executor, String, Clock, String, HttpHeaders)
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
-
blockingGet
protected abstract HttpFile blockingGet(Executor fileReadExecutor, String path, Clock clock, @Nullable String contentEncoding, HttpHeaders additionalHeaders)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
.- 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.
-