简体   繁体   English

Apache CXF/JAX-RS、Felix 和 Jetty

[英]Apache CXF/JAX-RS, Felix and Jetty

I have an existing group of bundles that together create a web application (including an instance of Jetty).我有一组现有的捆绑包,它们一起创建了一个 Web 应用程序(包括一个 Jetty 实例)。 A new requirement is to extend this application to provide a RESTful api (using JAX-RS).一个新需求是扩展此应用程序以提供 RESTful api(使用 JAX-RS)。

I was able to develop the majority of the RESTful API in isolation, away from the rest of the applciation.我能够独立开发大部分 RESTful API,远离应用程序的其余部分。 Without realising, the Apache CXF bundle I was using contained its own Jetty instance.不知不觉中,我使用的 Apache CXF 包包含它自己的 Jetty 实例。 So, in isolation, this worked fine.所以,孤立地看,这工作得很好。 When I merged the two halves of the application, the two instances' addresses conflicted.当我合并应用程序的两半时,两个实例的地址发生冲突。

This much I know for sure.这一点我肯定知道。

What I do not know is how to re-configure the RESTful API part of the application (JAX-RS) to use the existing Jetty instance.我不知道如何重新配置​​应用程序 (JAX-RS) 的 RESTful API 部分以使用现有的 Jetty 实例。 This page suggests the use of CXFServlet, but I cannot find much information on this.此页面建议使用 CXFServlet,但我找不到关于此的太多信息。

Could anybody shed some light or point me in the right direction?任何人都可以阐明或指出我正确的方向吗?

Edit: I should also mention that, currently, my endpoints use the JAX-RS annotations in a Java interface to map between an endpoint and mapped class.编辑:我还应该提到,目前,我的端点使用 Java 接口中的 JAX-RS 注释在端点和映射类之间进行映射。 I would prefer to keep this configuration method as opposed to XML or any other method.我更愿意保留这种配置方法,而不是 XML 或任何其他方法。

One option, which does not use Apache CXF, is to use the web components of Amdatu, which also support JAX-RS annotations.一种不使用 Apache CXF 的选项是使用 Amdatu 的 Web 组件,它也支持 JAX-RS 注释。 You can find more documentation about them at http://amdatu.org/components/web.html which explains how to setup your project with a separate Jetty instance.您可以在http://amdatu.org/components/web.html找到更多关于它们的文档,其中解释了如何使用单独的 Jetty 实例设置您的项目。 You might also want to watch the video at http://amdatu.org/howto/createwebapp.html which deals with the same subject.您可能还想在http://amdatu.org/howto/createwebapp.html观看处理相同主题的视频。

If you really want to use Apache CXF, there are two versions: an "all in one" that is pretty much self-contained (and therefore also includes Jetty) and a "modular" one that consists of many separate bundles.如果您真的想使用 Apache CXF,有两个版本:一个几乎是独立的(因此也包括 Jetty)的“一体化”版本和一个由许多独立包组成的“模块化”版本。 The latter in theory gives you the option to integrate with your own copy of Jetty, but you need to figure out what exact set of bundles you need based on their documentation at http://cxf.apache.org/docs/index.html后者理论上为您提供了与您自己的 Jetty 副本集成的选项,但您需要根据http://cxf.apache.org/docs/index.html上的文档确定您需要的确切捆绑包集

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM