我开发了一个自定义动态FTP组件,可与spring集成dsl一起使用。该组件在spring-boot 1.3.0下正常工作。但是,我必须在某些集成中更新spring-boot才能使用barrier dsl功能,请转到1.5.6。
从现在开始,尽管该组件仍然有效,我仍收到带有以下堆栈跟踪的警告:
pool-4-thread-1] o.s.i.expression.ExpressionUtils : Creating EvaluationContext with no beanFactory
java.lang.RuntimeException: No beanFactory
at org.springframework.integration.expression.ExpressionUtils.createStandardEvaluationContext(ExpressionUtils.java:79)
at org.springframework.integration.util.AbstractExpressionEvaluator.getEvaluationContext(AbstractExpressionEvaluator.java:113)
at org.springframework.integration.util.AbstractExpressionEvaluator.getEvaluationContext(AbstractExpressionEvaluator.java:99)
at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:169)
at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:157)
at org.springframework.integration.file.DefaultFileNameGenerator.generateFileName(DefaultFileNameGenerator.java:70)
at org.springframework.integration.file.remote.RemoteFileTemplate$1.doInSession(RemoteFileTemplate.java:305)
at org.springframework.integration.file.remote.RemoteFileTemplate$1.doInSession(RemoteFileTemplate.java:283)
at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:435)
at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:283)
at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:273)
at org.springframework.integration.file.remote.RemoteFileTemplate.send(RemoteFileTemplate.java:265)
at org.springframework.integration.file.remote.handler.FileTransferringMessageHandler.handleMessageInternal(FileTransferringMessageHandler.java:170)
at net.afferolab.ftp.dsl.handler.DynamicFileTransferringMessageHandler.handleMessageInternal(DynamicFileTransferringMessageHandler.java:37)
堆栈跟踪的最后一行表示我的自定义组件。
这是我的自定义ftp处理程序的一部分:
@Override
public void handleMessageInternal(Message<?> message) throws Exception {
DynamicSessionFactory.FtpCredentials credentials = new DynamicSessionFactory.FtpCredentials(
DynamicSessionFactory.FtpProtocol.valueOf(this.evaluateExpression(this.protocolExpression, String.class, message)),
this.evaluateExpression(this.hostExpression, String.class, message),
this.evaluateExpression(this.usernameExpression, String.class, message),
this.evaluateExpression(this.passwordExpression, String.class, message),
this.evaluateExpression(this.portExpression, Integer.class, message)
);
this.dynamicSessionFactory.setCredentials(credentials);
super.handleMessageInternal(message);
}
private <T> T evaluateExpression(Expression expression, Class<T> expectedType, Message<?> message) {
ExpressionEvaluatingMessageProcessor<T> expressionEvaluatingMessageProcessor = new ExpressionEvaluatingMessageProcessor<>(expression, expectedType);
expressionEvaluatingMessageProcessor.setBeanFactory(this.getBeanFactory());
return expressionEvaluatingMessageProcessor.processMessage(message);
}
这是流内部用法的示例:
.publishSubscribeChannel(ps -> ps
.subscribe(sf -> sf.handle(DynamicFtp.outboundAdapter()
.protocolExpression("headers[ftp_info].ftpProtocol")
.hostExpression("headers[ftp_info].ftpServerUrl")
.portExpression("headers[ftp_info].ftpServerPort")
.usernameExpression("headers[ftp_info].ftpUsername")
.passwordExpression("headers[ftp_info].ftpPassword")
.remoteDirectoryExpression("headers[ftp_info].ftpDirectory")
.autoCreateDirectory(true))
)
// ...
我想了解我是否应该担心此警告,以及为什么不能通过以下方式设置bean工厂:
expressionEvaluatingMessageProcessor.setBeanFactory(this.getBeanFactory());
谢谢。