apache-camel - Apache Camel as file explorer
问题描述
I need a way to show the content of a (remote) directory and, since the main application makes an intensive use of Apache Camel, I would like to rely on Apache Camel once more to accomplish this task.
So, the goal is to have a file explorer view which lists the base directory content (directories and files) and, by clicking on a given directory, the view should be refreshed by showing its content, and so on... a sort of FTP client (e.g. WinSCP, FileZilla, etc.) to let the user navigate a directory, which could be remote or local, depending on the context.
If I had to do it with Apache Camel
, I would use:
- the
file component
to gather local directories content - the
sftp component
to gather remote directories content
Then, starting from the given base directory, I would use recursive=true
to retrieve its full content (so, all files contained by the base directory and all sub-directories). That way, by mapping the result in a tree and keeping it in memory, I would be able to identify the directories structure and show to the user only a specific sub-set of information, depending on its navigation.
However, this approach has at least three side-effects:
- since the full structure is immediately retrieved at once, it wouldn't be possible to lazy load the given node, accordingly to the user navigation
- at the same way, it would be necessary to keep the full structure in memory, even if the user is viewing a leaf containing, for instance, a single file
- it wouldn't be possible to show empty directories... as far as I know, in fact, Camel reads files only so, in case a directory /D contains the file
F.txt
and the empty directory/E
, the Camel component would return/D/F.txt
but not/D/E
, which is a directory
Points 1 and 2 could probably be fixed by specifying a maxDepth=2
, in order to identify all files and all directories of the current level... but, again, considering the following structure:
root
|_ file1.txt
|_ sub-dir-1
|_ sub-dir-1-A
|_ nested-file.txt
|_ sub-dir-2
|_ file2.txt
The file component
, starting from root
and having recursive=true
and maxDepth=2
, would only return
- /root/file1.txt
- /root/sub-dir-2/file2.txt
(no sub-dir-1
, which doesn't directly contains files).
So, my questions are:
- Is Apache Camel the right choice?
- Is there a better way, in Apache Camel, to navigate a given directory?
- Is it possible, in Apache Camel, to retrieve information about empty directories too?
解决方案
Ad 1) Probably not - its an integration library, not a directory listening tool
Ad 2) No its not a directory listening tool
Ad 3) No its for files only.
推荐阅读
- aws-sdk - 使用 SageMaker 对象检测进行预测的图像大小?
- flutter - Flutter 有很多嵌套的小部件是不是很糟糕?
- java-8 - AOSP 构建期间 API 更改错误。怎么修?
- javascript - nodejs 加密模块 privateEncrypt() 总是返回相同的结果
- android - 在三星设备 (SM-J200F-sdk 22) 中调用 ACTION_VIEW (geo / map) 的意图时应用程序崩溃但适用于许多其他设备!有什么解决办法吗?
- spring - 减小 Springboot Jar 的大小
- javascript - React Ref没有在表单中获取文本输入字段数据
- shopify - 为什么 Neto/Shopify 使用自己的模板语言?
- wordpress - Git 状态 - 仅列出有更改的直接子文件夹,而不是内部文件
- php - 如何使用 db 中的存储结构恢复 jquery ui 可排序列表