Spring 将Camel路由公开为Web容器下的REST服务

Spring 将Camel路由公开为Web容器下的REST服务,spring,rest,restlet,apache-camel,cxfrs,Spring,Rest,Restlet,Apache Camel,Cxfrs,我有一个驼峰路径,我想将其公开为REST Web服务。应用程序部署在Web容器(Jetty/Tomcat)上,Spring也用于DI和其他“基础设施”方面 我查看了camel-restlet和camel-cxfrs组件,虽然它们都支持将路由公开为REST服务,但我无法找到如何避免启动单独的服务器。我真正想要的是能够以类似于为SpringWS入站端点定义路由的方式定义驼峰路由,例如 from("restlet://application/user/{id}").to(...) Web应用程序的配

我有一个驼峰路径,我想将其公开为REST Web服务。应用程序部署在Web容器(Jetty/Tomcat)上,Spring也用于DI和其他“基础设施”方面

我查看了
camel-restlet
camel-cxfrs
组件,虽然它们都支持将路由公开为REST服务,但我无法找到如何避免启动单独的服务器。我真正想要的是能够以类似于为SpringWS入站端点定义路由的方式定义驼峰路由,例如

from("restlet://application/user/{id}").to(...)
Web应用程序的配置应负责接受请求并将其传输到适当的端点

我不得不承认,我很惊讶我没有找到足够的关于这个主题的信息,我不认为我的要求很奇怪。

参见这个例子

对于apachecxf,您可以使用servlet传输,它允许您将Tomcat/Jetty作为主机容器

如果您使用OSGi,请查看以下内容:
它展示了如何将CXF与OSGi HTTP服务结合使用,这对CXFRS也应该起作用。

这是一个迟来的答案,但可能会帮助其他人

ApacheCamel现在似乎支持使用主机容器(例如Tomcat/Jetty)公开Restlet web服务

================8 在webapp中使用restletservlet 从Camel 2.8开始提供 在servlet容器中配置Restlet应用程序有三种可能的方法,使用子类SpringServerServlet可以通过注入Restlet组件在Camel中实现配置。 在servlet容器中使用restletservlet可以使用uri中的相对路径配置路由(消除硬编码绝对uri的限制),并使宿主servlet容器能够处理传入请求(而不必在新端口上生成单独的服务器进程)。 要进行配置,请将以下内容添加到camel-context.xml

<camelContext>
  <route id="RS_RestletDemo">
    <from uri="restlet:/demo/{id}" />
    <transform>
      <simple>Request type : ${header.CamelHttpMethod} and ID : ${header.id}</simple>
    </transform>
  </route> 
</camelContext>



<bean id="RestletComponent" class="org.restlet.Component" />

<bean id="RestletComponentService" class="org.apache.camel.component.restlet.RestletComponent">
  <constructor-arg index="0">
    <ref bean="RestletComponent" />
  </constructor-arg>
</bean>
And add this to your web.xml;
<!-- Restlet Servlet -->
<servlet>
  <servlet-name>RestletServlet</servlet-name>
  <servlet-class>org.restlet.ext.spring.SpringServerServlet</servlet-class>
  <init-param>
    <param-name>org.restlet.component</param-name>
    <param-value>RestletComponent</param-value>
  </init-param>
</servlet>

<servlet-mapping>
  <servlet-name>RestletServlet</servlet-name>
  <url-pattern>/rs/*</url-pattern>
</servlet-mapping>
==================剪断>8========================


这一信息是在2014年1月16日的底部找到的,克劳斯,谢谢你指出这一点。我能够想出如何实现我的目标。不幸的是,我觉得我将不得不完全避免使用camel cxfr。虽然我是Camel的忠实粉丝,但我发现REST集成非常不直观和繁琐。看起来我将直接使用CXF-RS功能,并从JAX-RS注释类.P.S显式调用Camel路由。很高兴在下一版的Camel-in-action中看到专门介绍REST WS的章节Camel-restlet更简单、更轻量级,它基于resetlet.org REST框架。是的,我认为camel cxf/cxfrs需要更好的文档。而且ApacheCXF是一个非常大/复杂的框架。我想如果我们添加一个camel jersey,它看起来像是一个很好的REST框架。是的,camel restlet看起来很适合我的需要,但是无法找到关于如何在不启动单独服务器的情况下公开服务的信息,这让我抓狂。
http://localhost:8080/mywebapp/rs/demo/1234

where localhost:8080 is the server and port of your servlet container