在使用XML命名空间几年之后,我才刚刚开始使用。
我喜欢DSL,但是我对Java 8知识的缺乏阻碍了我的工作。
例如,如何用Java7编写下面的示例代码,我对e -> e.id("sendMailEndpoint"))感到困惑,因为我不知道e是什么类型!
@Bean
public IntegrationFlow sendMailFlow() {
return IntegrationFlows.from("sendMailChannel")
.handle(Mail.outboundAdapter("localhost")
.port(smtpPort)
.credentials("user", "pw")
.protocol("smtp")
.javaMailProperties(p -> p.put("mail.debug", "true")),
e -> e.id("sendMailEndpoint"))
.get();
}亲切的问候
戴维/
发布于 2015-02-19 10:18:53
任何Lambda都是内联功能接口实现。如果您查看该.handle()方法的源代码(或至少是.handle()),您将看到e param是Consumer<GenericEndpointSpec<H>>,因此对于非Java 8环境,您只需在以下地方实现该接口:
.handle(Mail.outboundAdapter("localhost")
.port(smtpPort)
.credentials("user", "pw")
.protocol("smtp")
.javaMailProperties(p -> p.put("mail.debug", "true")),
new Consumer<GenericEndpointSpec<MailSendingMessageHandler>>() {
@Override
public void accept(GenericEndpointSpec<MailSendingMessageHandler> e) {
e.id("sendMailEndpoint");
}
})javaMailProperties也是如此。
https://stackoverflow.com/questions/28603533
复制相似问题