使用JAX-RS + JAX-WS的CXF和Google Guice [英] CXF and Google Guice using JAX-RS + JAX-WS

查看:103
本文介绍了使用JAX-RS + JAX-WS的CXF和Google Guice的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将CXF与Google Guice集成.我已经在项目中使用Guice,并且希望避免添加额外的依赖项.

I would like to integrate CXF with Google Guice. I am already using Guice in my project and I want to avoid adding extra dependencies.

CXF是我的选择,因为其中一项要求是能够向服务的用户提供XML,JSON,JSONP和SOAP接口,而无需重复代码(现在我们有SOAP特定的类,对于XML,我们使用Struts,对于JSON,我们编写了自己的解析器(我知道,我也感到很脏).

CXF was my choice because one of the requirements is to be able to provide XML, JSON, JSONP and SOAP interface to the users of the services without having duplicate code (right now we have SOAP-specific classes, for XML we use Struts and for JSON we wrote our own parsers, I know, I feel dirty too).

无论如何, afaik ,CXF可以满足此要求,所以看来我对CXF感到困惑.

Anyway, afaik, CXF can fulfill this requirement, so it seems I'm stuck with CXF.

关于如何将Guice与CXF集成的任何想法或指示或建议?我曾想过扩展CXFNonSpringJaxrsServlet类并将Guice入侵其中,但是似乎我会做别人已经做过的事情.

Any ideas or pointers or advice on how to integrate Guice with CXF? I thought of extending the CXFNonSpringJaxrsServlet class and hack Guice into it, but it somehow seems like I would be doing something that someone else has already done.

推荐答案

在CXF 2.4.x中,CXF不再使用Spring在内部进行自我配置.因此,没有Spring,您几乎可以做任何事情.

With CXF 2.4.x, CXF no longer uses Spring to internally configure itself. Thus, you can do pretty much anything without Spring.

配置部分绝对是一个问题.但是,所有的Spring配置东西只是CXF API的薄包装.因此,您几乎可以通过API进行所有配置.您可能只需要多挖一点即可.

The configuration parts are definitely an issue. However, all the spring configuration stuff is just thin wrappers over the CXF API's. Thus, you can configure pretty much everything via the API's. You may just need to dig a little bit more.

以CXF 2.4为例,我们现在开始支持在OSGi中使用Blueprint而不是Spring.蓝图支持不需要任何Spring内容,而是从中建模的.

As an example, with CXF 2.4, we now have started to support using Blueprint instead of Spring in OSGi. The blueprint support doesn't require any of the Spring stuff, but is modelled from it.

这篇关于使用JAX-RS + JAX-WS的CXF和Google Guice的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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