Camel-Jersey 集成 [英] Camel-Jersey Integration

查看:15
本文介绍了Camel-Jersey 集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用 Jersey 2 作为 Rest 接口.我需要使其适应使用 CXF 传递 SOAP 请求的现有系统.我知道我应该使用 CXF-RS 但...这不是客户想要的.

I have a requirement to use Jersey 2 as the Rest interface. I need to adapt this to an existing system which has used CXF to pass in SOAP requests. I know I should use CXF-RS but... it's not what the client wants.

我正在从 XML 模型自动生成 WADL 并使用它来自动生成资源类(使用 CXF,但可以说是在幕后),所以我真的不想从内部调用生产者模板资源类.

I am auto-generating a WADL from a XML model and using that to autogenerate the resource classes (using CXF, but behind the scenes so to speak), so I really don't want to call a producer template from within the resource class.

因此,我认为我可以将 REST 资源类包装在可以捕获必要信息的方面.进一步查看它,我意识到有后处理过滤器可以为我提供足够的信息来使用从相关资源方法中获取的适当信息来触发 Camel 生产者模板.这就是我计划前往的地方.

So, I have thought that I could wrap the REST resource class in aspects that would capture the necessary information. Looking at it further I realise there are post-processing filters which would give me enough information to fire off a Camel producer template with the appropriate information taken from the resource method in question. That's where I am planning on heading.

然而:我真的想通过创建一个真正的 Camel 端点来做我想做的事情,从而做一些更稳定、可维护和可重用的事情.暂时是消费者.我知道这是可能的.但我的问题是 - 我从哪里开始?我如何将 Jax-RS 资源类映射到交换对象,并将参数映射到标头.看起来好像应该很简单,但我并不真正理解一个过程,因为它可以将资源方法劫持到 Camel 组件中的使用者方法中.我主要想利用从 xml 到它允许的对象的自动 JAXB 转换.

And yet: I really want to do something a bit more stasifying and maintainable and reusable by creating a real Camel endpoint to do what I want. A consumer for now. I know this is possible. But my question is - where do I start? How do I map the Jax-RS resource classes to, say an exchange object and the parameters to headers. It seems as if it should be simple but I don't really understand the process by which one can as it were hijack the resource methods into the consumer method in a Camel component. Primarily I want to take advantage of the automatic JAXB conversion from xml to objects that it allows for.

推荐答案

看看这个 example 看看是否有帮助,基本上它公开了一个REST 端点并将生产者模板注入到调用 activemq 端点的 bean 中.

Have a look at this example and see if that helps, basically it exposes a REST endpoint and injects producer template into a bean that calls an activemq endpoint.

这篇关于Camel-Jersey 集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆