我正在寻找一种以Stream
干净的方式优化处理的方法.
我有类似的东西:
try (Stream<Path> stream = Files.list(targetDir)) {
Map<String, List<Path>> targetDirFilteredAndMapped = stream.parallel()
.filter(path -> sd.containsKey(md5(path)))
.collect(Collectors.groupingBy(path -> md5(path)));
} catch (IOException ioe) { // manage exception }
Run Code Online (Sandbox Code Playgroud)
由于该md5
功能非常昂贵,我想知道是否有办法每个文件只调用一次.
有什么建议?
我需要构建一个动态路径,将属性文件中定义的值与 SpEL 表达式的结果相结合,但找不到正确的语法来实现这一目标。
我的情况是这样的:
<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:myprop.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="false"/>
</bean>
<bean id="fileNameToFSTree"
class="foo.bar.FileNameToFSTree"/>
<int-file:outbound-channel-adapter id="filesOut"
auto-create-directory="true"
directory-expression="${outDir} + @fileNameToFSTree.nameToTree(payload)"
delete-source-files="true"/>
Run Code Online (Sandbox Code Playgroud)
鉴于该myprop.properties
文件包含一个变量outDir
,我想在directory-expression
文件出站的前面添加该变量。
显然它会定期评估,${outDir}
但我得到以下异常:
org.springframework.expression.spel.SpelParseException: Expression [/tmp/output + @fileNameToFSTree.nameToTree(payload)] @0: EL1070E: Problem parsing left operand
Run Code Online (Sandbox Code Playgroud)
我在文档或示例中没有发现这种情况的痕迹。
有什么提示吗?
我需要创建一个小型的Spring Integration应用程序,将JDBC源代码表与另一个表同步,我只需要偶尔启动一次该脚本.
我想从入站通道适配器进行一次轮询(等待消息流经链)并退出应用程序.
我找不到任何明显的方法:任何建议?