【发布时间】:2015-09-27 21:07:19
【问题描述】:
在我的应用程序中,我有一些 xml 文件存储在声明我的路由的文件夹中。我想在应用程序引导上传我所有的路线并将它们存储在我的骆驼上下文中。换句话说,我想自动发现存储在这些 xml 文件中的路由。
这里是包含路由的文件示例
<?xml version="1.0" encoding="UTF-8"?>
<routeContext id="myRoute" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="file:C:/LocalFTPServer" />
<log message="Got a file!" loggingLevel="INFO" loggerRef="myLogger" />
<choice>
<when>
<simple>${file:ext} == 'csv'</simple>
<log message="I'm going to email you!" loggingLevel="INFO"
loggerRef="myLogger" />
</when>
<otherwise>
<log message="File extension wrong." loggingLevel="WARN"
loggerRef="myLogger" />
</otherwise>
</choice>
</route>
</routeContext>
这是我的应用程序上下文
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<import resource="beans/beans.xml" />
<camelContext xmlns="http://camel.apache.org/schema/spring">
</camelContext>
</beans>
【问题讨论】:
-
<import resource="classpath*:/routes/*.xml"/>呢? -
以这种方式导入文件,但不会在骆驼上下文中“注册”其中包含的路由。我正在寻找可以做到这一点的东西。
标签: java xml spring apache-camel