如何将jaxb对象传递给camelconfig xml文件

发布于 2025-01-05 05:55:48 字数 606 浏览 2 评论 0 原文

我正在尝试在骆驼路由中使用 jaxb。我尝试使用 jaxb 从 xml 加载路由器并完成它。在方法内部,我创建了 jaxb 对象并在 xml 中解组路由器(从 xml 加载路由器)。

我的代码:

    JAXBContext jaxb = JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES);
    Unmarshaller unmarshaller = jaxb.createUnmarshaller();
    Resource rs = new ClassPathResource("cameltest.xml");
    Object value = unmarshaller.unmarshal(rs.getInputStream());
    RoutesDefinition routes = (RoutesDefinition) value;

    context.addRouteDefinitions(routes.getRoutes());

要求:

而不是在 java 文件中执行它。我需要当调用服务中的方法时,方法内的 jaxb 对象应该触发包含流的 xml(路由器概念)。帮我........

I am trying to use jaxb in camel routing.I have tried to load router from xml using jaxb and got it done. Inside a method I have created jaxb object and unmarshaller the router in xml(loaded router from xml).

my code:

    JAXBContext jaxb = JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES);
    Unmarshaller unmarshaller = jaxb.createUnmarshaller();
    Resource rs = new ClassPathResource("cameltest.xml");
    Object value = unmarshaller.unmarshal(rs.getInputStream());
    RoutesDefinition routes = (RoutesDefinition) value;

    context.addRouteDefinitions(routes.getRoutes());

Requirement:

Instead of doing it in java file. I need when a method in a service is called, the jaxb object inside the method should trigger off the xml which contains the flow (router concept). help me........

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晚雾 2025-01-12 05:55:48

在 Camel 路由中使用 JAXB 非常简单,如 JAXB。除非处理非常复杂,否则可以在 Spring 中完成,并且需要最少的代码。

您试图从代码中执行的操作是使用 JAXB 从 Camel xml 文件中提取路由,也许您想要创建动态路由器 - 我建议查看 EIP 模式 Camel 实现并选择诸如基于内容的路由器或动态路由器之类的东西。

Using JAXB in a Camel route is quite easy, as is shown in JAXB. Unless the processing is very complex it can be done in Spring and requires a minimal amount of code.

What it looks like you are trying to do from the code is extract the routes using JAXB from the Camel xml file, perhaps you are wanting to create dynamic router - I would suggest looking at the EIP Patterns that Camel implements and picking something like the Content Based Router or Dynamic Router.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文